From dbbd8a7377ff1e29e3e7f06a4e12766737739522 Mon Sep 17 00:00:00 2001 From: Hans Then Date: Sat, 27 Sep 2025 12:03:55 +0200 Subject: [PATCH 01/35] Make id generation customizable Branca/folium uses random numbers to generate ids. This has some disadvantages. E.g. in the streamlit-folium plugin they have to replace the random ids with predictable ids for comparison between streamlit runs. Also, in the folium tests, we have to normalize the variable names to compare between expected and actual results. This change in Branca makes it possible to override or customize id generation. This allows client libraries to experiment with new id generation schemes. --- branca/element.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/branca/element.py b/branca/element.py index 1912aca..f70bea6 100644 --- a/branca/element.py +++ b/branca/element.py @@ -53,7 +53,7 @@ class Element: def __init__(self, template=None, template_name=None): self._name = "Element" - self._id = hexlify(urandom(16)).decode() + self._id = self._generate_id() self._children = OrderedDict() self._parent = None self._template_str = template @@ -64,6 +64,10 @@ def __init__(self, template=None, template_name=None): elif template_name is not None: self._template = ENV.get_template(template_name) + @classmethod + def _generate_id(cls): + return hexlify(urandom(16)).decode() + def __getstate__(self): """Modify object state when pickling the object. From 58ea6ee2a0bc5e6b03db896c38bea7a59ca83e1a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:24:33 +0000 Subject: [PATCH 02/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.2.0 → 24.3.0](https://github.com/psf/black/compare/24.2.0...24.3.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3dd55c4..1e5033e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: args: ["--profile", "black", "--filter-files"] - repo: https://github.com/psf/black - rev: 24.2.0 + rev: 24.3.0 hooks: - id: black language_version: python3 From 89d0a348b085226b90603b6e8d10cc82994a83dd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 16:24:35 +0000 Subject: [PATCH 03/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.15.1 → v3.15.2](https://github.com/asottile/pyupgrade/compare/v3.15.1...v3.15.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e5033e..8a9cb04 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,7 +44,7 @@ repos: - --ignore-words-list=thex - repo: https://github.com/asottile/pyupgrade - rev: v3.15.1 + rev: v3.15.2 hooks: - id: pyupgrade args: From 372fa3a0467f602f5039259c42da102ac61a3a08 Mon Sep 17 00:00:00 2001 From: Frank Anema <33519926+Conengmo@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:19:48 +0200 Subject: [PATCH 04/35] Remove `split_six` utility function (#161) --- branca/utilities.py | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/branca/utilities.py b/branca/utilities.py index 5f53145..4bb3540 100644 --- a/branca/utilities.py +++ b/branca/utilities.py @@ -18,11 +18,6 @@ from jinja2 import Environment, PackageLoader -try: - import pandas as pd -except ImportError: - pd = None - try: import numpy as np except ImportError: @@ -203,39 +198,6 @@ def color_brewer(color_code, n=6): return color_scheme -def split_six(series=None): - """ - Given a Pandas Series, get a domain of values from zero to the 90% quantile - rounded to the nearest order-of-magnitude integer. For example, 2100 is - rounded to 2000, 2790 to 3000. - - Parameters - ---------- - series: Pandas series, default None - - Returns - ------- - list - - """ - if pd is None: - raise ImportError("The Pandas package is required" " for this functionality") - if np is None: - raise ImportError("The NumPy package is required" " for this functionality") - - def base(x): - if x > 0: - base = pow(10, math.floor(math.log10(x))) - return round(x / base) * base - else: - return 0 - - quants = [0, 50, 75, 85, 90] - # Some weirdness in series quantiles a la 0.13. - arr = series.values - return [base(np.percentile(arr, x)) for x in quants] - - def image_to_url(image, colormap=None, origin="upper"): """Infers the type of an image argument and transforms it into a URL. From c49db60535f91836d45f25638dae294f59b50f77 Mon Sep 17 00:00:00 2001 From: Martin Fleischmann Date: Wed, 3 Apr 2024 19:27:21 +0200 Subject: [PATCH 05/35] COMPAT: explictly cast numpy floats to native floats (#163) * COMPAT: explictly cast numpy floats to native floats * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- branca/colormap.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/branca/colormap.py b/branca/colormap.py index b622b3a..bf3cc7a 100644 --- a/branca/colormap.py +++ b/branca/colormap.py @@ -95,9 +95,13 @@ def __init__(self, vmin=0.0, vmax=1.0, caption="", max_labels=10): def render(self, **kwargs): """Renders the HTML representation of the element.""" self.color_domain = [ - self.vmin + (self.vmax - self.vmin) * k / 499.0 for k in range(500) + float(self.vmin + (self.vmax - self.vmin) * k / 499.0) for k in range(500) ] self.color_range = [self.__call__(x) for x in self.color_domain] + + # sanitize possible numpy floats to native python floats + self.index = [float(i) for i in self.index] + if self.tick_labels is None: self.tick_labels = legend_scaler(self.index, self.max_labels) From fb23a589781d6e5b8f694cf10c7c55cd81f590c3 Mon Sep 17 00:00:00 2001 From: Frank Anema <33519926+Conengmo@users.noreply.github.com> Date: Wed, 3 Apr 2024 19:28:14 +0200 Subject: [PATCH 06/35] Remove empty plugins package (#162) --- branca/plugins/__init__.py | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 branca/plugins/__init__.py diff --git a/branca/plugins/__init__.py b/branca/plugins/__init__.py deleted file mode 100644 index 7574df5..0000000 --- a/branca/plugins/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -""" -Branca plugins --------------- - -Add different objects/effects in a branca webpage. -""" - -__all__ = [] From 94846ef90a240408c339f5943f0ebfeb51b23c9c Mon Sep 17 00:00:00 2001 From: Frank Anema <33519926+Conengmo@users.noreply.github.com> Date: Fri, 5 Apr 2024 09:43:59 +0200 Subject: [PATCH 07/35] Drop Py3.7, add Py3.12 (#164) --- .github/workflows/test_code.yml | 12 ++---------- setup.py | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test_code.yml b/.github/workflows/test_code.yml index 638a558..d705c01 100644 --- a/.github/workflows/test_code.yml +++ b/.github/workflows/test_code.yml @@ -11,16 +11,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.11"] - # We only run latest Python on macOS and Windows to save resources. - include: - - os: ubuntu-latest - python-version: "3.8" - - os: ubuntu-latest - python-version: "3.9" - - os: ubuntu-latest - python-version: "3.10" + os: [ubuntu-latest, windows-latest] + python-version: ["3.8", "3.12"] steps: - uses: actions/checkout@v3 diff --git a/setup.py b/setup.py index e85fd55..9abc069 100644 --- a/setup.py +++ b/setup.py @@ -53,11 +53,11 @@ def walk_subpkg(name): keywords="data visualization", classifiers=[ "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", "Development Status :: 5 - Production/Stable", ], From 74ef14a527656a3e9e813363cef6dccf0b8dd35d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:24:55 +0000 Subject: [PATCH 08/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.5.0...v4.6.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a9cb04..cd716e5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: trailing-whitespace - id: check-ast From 1cd98a963e7e196d3fc7e5bcf9a5b707717c998e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:24:40 +0000 Subject: [PATCH 09/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.3.0 → 24.4.0](https://github.com/psf/black/compare/24.3.0...24.4.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd716e5..408409c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: args: ["--profile", "black", "--filter-files"] - repo: https://github.com/psf/black - rev: 24.3.0 + rev: 24.4.0 hooks: - id: black language_version: python3 From 06fd0a179cbe6f60b912fae31ff87c4c5d094d6e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:24:58 +0000 Subject: [PATCH 10/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.4.0 → 24.4.2](https://github.com/psf/black/compare/24.4.0...24.4.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 408409c..49159b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: args: ["--profile", "black", "--filter-files"] - repo: https://github.com/psf/black - rev: 24.4.0 + rev: 24.4.2 hooks: - id: black language_version: python3 From 722ff0c4bb2db72ec8f29a2d07efa60853957bb8 Mon Sep 17 00:00:00 2001 From: Sagar Mishra <54197164+achieveordie@users.noreply.github.com> Date: Wed, 1 May 2024 23:10:09 +0530 Subject: [PATCH 11/35] add pre-commit to dev requirements (#169) --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 94d258b..549938d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,6 +10,7 @@ jupyter nbsphinx nbval numpy +pre-commit pylint pytest pytest-cov From d9ed4f9465d16c957dab477eeaafdc715fc9c398 Mon Sep 17 00:00:00 2001 From: Thomas Burnett Date: Wed, 8 May 2024 01:12:58 +1000 Subject: [PATCH 12/35] ColorMap text color (#160) * Add ability to specify text_color for ColorMap. * Modify colormap example to include text color. * Make text_color comment clearer. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Return executionCount to 1 * Use implied line contrinuation to shorten lines * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Apply black autoformatting. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * ENH: add ability to change color of legend's text * Minor fixes for new text_color argument * add default value to docstring --------- Co-authored-by: ThomasBur Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Frank <33519926+Conengmo@users.noreply.github.com> --- branca/colormap.py | 50 +++++++++++++++++++++++++++++---- branca/templates/color_scale.js | 2 ++ examples/Custom_colormap.ipynb | 7 +++-- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/branca/colormap.py b/branca/colormap.py index bf3cc7a..e5dd839 100644 --- a/branca/colormap.py +++ b/branca/colormap.py @@ -72,19 +72,29 @@ class ColorMap(MacroElement): The right bound of the color scale. caption: str A caption to draw with the colormap. + text_color: str, default "black" + The color for the text. max_labels : int, default 10 Maximum number of legend tick labels """ _template = ENV.get_template("color_scale.js") - def __init__(self, vmin=0.0, vmax=1.0, caption="", max_labels=10): + def __init__( + self, + vmin=0.0, + vmax=1.0, + caption="", + text_color="black", + max_labels=10, + ): super().__init__() self._name = "ColorMap" self.vmin = vmin self.vmax = vmax self.caption = caption + self.text_color = text_color self.index = [vmin, vmax] self.max_labels = max_labels self.tick_labels = None @@ -185,22 +195,32 @@ def _repr_html_(self): for i in range(self.width) ], ) - + '{}'.format( # noqa + + ( + '{}' + ).format( + self.text_color, self.vmin, ) + "".join( [ ( - '{}' # noqa - ).format(x_ticks[i], val_ticks[i]) + '{}' + ).format(x_ticks[i], self.text_color, val_ticks[i]) for i in range(1, nb_ticks - 1) ], ) - + '{}'.format( + + ( + '{}' + ).format( self.width, + self.text_color, self.vmax, ) - + '{}'.format( + + '{}'.format( + self.text_color, self.caption, ) + "" @@ -233,6 +253,10 @@ class LinearColormap(ColorMap): vmax : float, default 1. The maximal value for the colormap. Values higher than `vmax` will be bound directly to `colors[-1]`. + caption: str + A caption to draw with the colormap. + text_color: str, default "black" + The color for the text. max_labels : int, default 10 Maximum number of legend tick labels tick_labels: list of floats, default None @@ -245,6 +269,7 @@ def __init__( vmin=0.0, vmax=1.0, caption="", + text_color="black", max_labels=10, tick_labels=None, ): @@ -252,6 +277,7 @@ def __init__( vmin=vmin, vmax=vmax, caption=caption, + text_color=text_color, max_labels=max_labels, ) self.tick_labels = tick_labels @@ -415,6 +441,7 @@ def to_step( ] caption = self.caption + text_color = self.text_color return StepColormap( colors, @@ -422,6 +449,7 @@ def to_step( vmin=index[0], vmax=index[-1], caption=caption, + text_color=text_color, max_labels=max_labels, tick_labels=self.tick_labels, ) @@ -439,6 +467,7 @@ def scale(self, vmin=0.0, vmax=1.0, max_labels=10): vmin=vmin, vmax=vmax, caption=self.caption, + text_color=self.text_color, max_labels=max_labels, ) @@ -469,6 +498,10 @@ class StepColormap(ColorMap): vmax : float, default 1. The maximal value for the colormap. Values higher than `vmax` will be bound directly to `colors[-1]`. + caption: str + A caption to draw with the colormap. + text_color: str, default "black" + The color for the text. max_labels : int, default 10 Maximum number of legend tick labels tick_labels: list of floats, default None @@ -482,6 +515,7 @@ def __init__( vmin=0.0, vmax=1.0, caption="", + text_color="black", max_labels=10, tick_labels=None, ): @@ -489,6 +523,7 @@ def __init__( vmin=vmin, vmax=vmax, caption=caption, + text_color=text_color, max_labels=max_labels, ) self.tick_labels = tick_labels @@ -544,6 +579,8 @@ def to_linear(self, index=None, max_labels=10): index=index, vmin=self.vmin, vmax=self.vmax, + caption=self.caption, + text_color=self.text_color, max_labels=max_labels, ) @@ -560,6 +597,7 @@ def scale(self, vmin=0.0, vmax=1.0, max_labels=10): vmin=vmin, vmax=vmax, caption=self.caption, + text_color=self.text_color, max_labels=max_labels, ) diff --git a/branca/templates/color_scale.js b/branca/templates/color_scale.js index 18cd01a..c49fd24 100644 --- a/branca/templates/color_scale.js +++ b/branca/templates/color_scale.js @@ -32,6 +32,7 @@ {{this.get_name()}}.g = {{this.get_name()}}.svg.append("g") .attr("class", "key") + .attr("fill", {{ this.text_color | tojson }}) .attr("transform", "translate(25,16)"); {{this.get_name()}}.g.selectAll("rect") @@ -51,5 +52,6 @@ {{this.get_name()}}.g.call({{this.get_name()}}.xAxis).append("text") .attr("class", "caption") .attr("y", 21) + .attr("fill", {{ this.text_color | tojson }}) .text({{ this.caption|tojson }}); {% endmacro %} diff --git a/examples/Custom_colormap.ipynb b/examples/Custom_colormap.ipynb index cc02b44..da770c3 100644 --- a/examples/Custom_colormap.ipynb +++ b/examples/Custom_colormap.ipynb @@ -9,10 +9,10 @@ { "data": { "text/html": [ - "3.24.45.66.77.99.110.3Unemployment rate" + "3.24.45.66.87.99.110.3Unemployment rate" ], "text/plain": [ - "" + "" ] }, "execution_count": 1, @@ -28,6 +28,7 @@ "vmax = 10.3\n", "colormap = colormap_choice.scale(vmin, vmax)\n", "colormap.caption = 'Unemployment rate'\n", + "colormap.text_color = 'cyan'\n", "colormap" ] } @@ -48,7 +49,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.12" } }, "nbformat": 4, From 875878fc8d2e979ae65418db4f6c5b437647163b Mon Sep 17 00:00:00 2001 From: Frank Anema <33519926+Conengmo@users.noreply.github.com> Date: Sat, 18 May 2024 11:00:18 +0200 Subject: [PATCH 13/35] Add type hints (#146) * Update colormap.py * Create test_mypy.yml * add Mypy requirement * Update pyproject.toml * Update element.py * utilities.py wip * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update branca/utilities.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Restore Div and MacroElement * Update test_mypy.yml * Update colormap.py * Update element.py * Update utilities.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * error after rebase * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" This reverts commit e21b6d4dc5c5510da8c20767d871d07f27253b70. * another rebase artefact :/ --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/test_mypy.yml | 33 ++++++ branca/colormap.py | 176 ++++++++++++++++------------- branca/element.py | 190 +++++++++++++++++++++----------- branca/utilities.py | 60 +++++----- pyproject.toml | 3 + requirements-dev.txt | 1 + 6 files changed, 292 insertions(+), 171 deletions(-) create mode 100644 .github/workflows/test_mypy.yml diff --git a/.github/workflows/test_mypy.yml b/.github/workflows/test_mypy.yml new file mode 100644 index 0000000..96715e0 --- /dev/null +++ b/.github/workflows/test_mypy.yml @@ -0,0 +1,33 @@ +name: Mypy type hint checks + +on: + pull_request: + push: + branches: + - main + +jobs: + run: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Micromamba env + uses: mamba-org/setup-micromamba@v1 + with: + environment-name: TEST + create-args: >- + python=3 + --file requirements.txt + --file requirements-dev.txt + + - name: Install branca from source + shell: bash -l {0} + run: | + python -m pip install -e . --no-deps --force-reinstall + + - name: Mypy test + shell: bash -l {0} + run: | + mypy branca diff --git a/branca/colormap.py b/branca/colormap.py index e5dd839..2e76ba5 100644 --- a/branca/colormap.py +++ b/branca/colormap.py @@ -9,51 +9,67 @@ import json import math import os +from typing import Dict, List, Optional, Sequence, Tuple, Union from jinja2 import Template from branca.element import ENV, Figure, JavascriptLink, MacroElement from branca.utilities import legend_scaler -rootpath = os.path.abspath(os.path.dirname(__file__)) +rootpath: str = os.path.abspath(os.path.dirname(__file__)) with open(os.path.join(rootpath, "_cnames.json")) as f: - _cnames = json.loads(f.read()) + _cnames: Dict[str, str] = json.loads(f.read()) with open(os.path.join(rootpath, "_schemes.json")) as f: - _schemes = json.loads(f.read()) + _schemes: Dict[str, List[str]] = json.loads(f.read()) -def _is_hex(x): +TypeRGBInts = Tuple[int, int, int] +TypeRGBFloats = Tuple[float, float, float] +TypeRGBAInts = Tuple[int, int, int, int] +TypeRGBAFloats = Tuple[float, float, float, float] +TypeAnyColorType = Union[TypeRGBInts, TypeRGBFloats, TypeRGBAInts, TypeRGBAFloats, str] + + +def _is_hex(x: str) -> bool: return x.startswith("#") and len(x) == 7 -def _parse_hex(color_code): +def _parse_hex(color_code: str) -> TypeRGBAFloats: return ( - int(color_code[1:3], 16), - int(color_code[3:5], 16), - int(color_code[5:7], 16), + _color_int_to_float(int(color_code[1:3], 16)), + _color_int_to_float(int(color_code[3:5], 16)), + _color_int_to_float(int(color_code[5:7], 16)), + 1.0, ) -def _parse_color(x): +def _color_int_to_float(x: int) -> float: + """Convert an integer between 0 and 255 to a float between 0. and 1.0""" + return x / 255.0 + + +def _color_float_to_int(x: float) -> int: + """Convert a float between 0. and 1.0 to an integer between 0 and 255""" + return int(x * 255.9999) + + +def _parse_color(x: Union[tuple, list, str]) -> TypeRGBAFloats: if isinstance(x, (tuple, list)): - color_tuple = tuple(x)[:4] - elif isinstance(x, (str, bytes)) and _is_hex(x): - color_tuple = _parse_hex(x) - elif isinstance(x, (str, bytes)): + return tuple(tuple(x) + (1.0,))[:4] # type: ignore + elif isinstance(x, str) and _is_hex(x): + return _parse_hex(x) + elif isinstance(x, str): cname = _cnames.get(x.lower(), None) if cname is None: raise ValueError(f"Unknown color {cname!r}.") - color_tuple = _parse_hex(cname) + return _parse_hex(cname) else: raise ValueError(f"Unrecognized color code {x!r}") - if max(color_tuple) > 1.0: - color_tuple = tuple(u / 255.0 for u in color_tuple) - return tuple(map(float, (color_tuple + (1.0,))[:4])) -def _base(x): +def _base(x: float) -> float: if x > 0: base = pow(10, math.floor(math.log10(x))) return round(x / base) * base @@ -78,15 +94,15 @@ class ColorMap(MacroElement): Maximum number of legend tick labels """ - _template = ENV.get_template("color_scale.js") + _template: Template = ENV.get_template("color_scale.js") def __init__( self, - vmin=0.0, - vmax=1.0, - caption="", - text_color="black", - max_labels=10, + vmin: float = 0.0, + vmax: float = 1.0, + caption: str = "", + text_color: str = "black", + max_labels: int = 10, ): super().__init__() self._name = "ColorMap" @@ -95,9 +111,9 @@ def __init__( self.vmax = vmax self.caption = caption self.text_color = text_color - self.index = [vmin, vmax] + self.index: List[float] = [vmin, vmax] self.max_labels = max_labels - self.tick_labels = None + self.tick_labels: Optional[Sequence[Union[float, str]]] = None self.width = 450 self.height = 40 @@ -127,7 +143,7 @@ def render(self, **kwargs): name="d3", ) # noqa - def rgba_floats_tuple(self, x): + def rgba_floats_tuple(self, x: float) -> TypeRGBAFloats: """ This class has to be implemented for each class inheriting from Colormap. This has to be a function of the form float -> @@ -137,37 +153,37 @@ def rgba_floats_tuple(self, x): """ raise NotImplementedError - def rgba_bytes_tuple(self, x): + def rgba_bytes_tuple(self, x: float) -> TypeRGBAInts: """Provides the color corresponding to value `x` in the form of a tuple (R,G,B,A) with int values between 0 and 255. """ - return tuple(int(u * 255.9999) for u in self.rgba_floats_tuple(x)) + return tuple(_color_float_to_int(u) for u in self.rgba_floats_tuple(x)) # type: ignore - def rgb_bytes_tuple(self, x): + def rgb_bytes_tuple(self, x: float) -> TypeRGBInts: """Provides the color corresponding to value `x` in the form of a tuple (R,G,B) with int values between 0 and 255. """ return self.rgba_bytes_tuple(x)[:3] - def rgb_hex_str(self, x): + def rgb_hex_str(self, x: float) -> str: """Provides the color corresponding to value `x` in the form of a string of hexadecimal values "#RRGGBB". """ return "#%02x%02x%02x" % self.rgb_bytes_tuple(x) - def rgba_hex_str(self, x): + def rgba_hex_str(self, x: float) -> str: """Provides the color corresponding to value `x` in the form of a string of hexadecimal values "#RRGGBBAA". """ return "#%02x%02x%02x%02x" % self.rgba_bytes_tuple(x) - def __call__(self, x): + def __call__(self, x: float) -> str: """Provides the color corresponding to value `x` in the form of a string of hexadecimal values "#RRGGBBAA". """ return self.rgba_hex_str(x) - def _repr_html_(self): + def _repr_html_(self) -> str: """Display the colormap in a Jupyter Notebook. Does not support all the class arguments. @@ -264,14 +280,14 @@ class LinearColormap(ColorMap): def __init__( self, - colors, - index=None, - vmin=0.0, - vmax=1.0, - caption="", - text_color="black", - max_labels=10, - tick_labels=None, + colors: Sequence[TypeAnyColorType], + index: Optional[Sequence[float]] = None, + vmin: float = 0.0, + vmax: float = 1.0, + caption: str = "", + text_color: str = "black", + max_labels: int = 10, + tick_labels: Optional[Sequence[float]] = None, ): super().__init__( vmin=vmin, @@ -280,7 +296,7 @@ def __init__( text_color=text_color, max_labels=max_labels, ) - self.tick_labels = tick_labels + self.tick_labels: Optional[Sequence[float]] = tick_labels n = len(colors) if n < 2: @@ -289,9 +305,9 @@ def __init__( self.index = [vmin + (vmax - vmin) * i * 1.0 / (n - 1) for i in range(n)] else: self.index = list(index) - self.colors = [_parse_color(x) for x in colors] + self.colors: List[TypeRGBAFloats] = [_parse_color(x) for x in colors] - def rgba_floats_tuple(self, x): + def rgba_floats_tuple(self, x: float) -> TypeRGBAFloats: """Provides the color corresponding to value `x` in the form of a tuple (R,G,B,A) with float values between 0. and 1. """ @@ -308,20 +324,20 @@ def rgba_floats_tuple(self, x): else: raise ValueError("Thresholds are not sorted.") - return tuple( + return tuple( # type: ignore (1.0 - p) * self.colors[i - 1][j] + p * self.colors[i][j] for j in range(4) ) def to_step( self, - n=None, - index=None, - data=None, - method=None, - quantiles=None, - round_method=None, - max_labels=10, - ): + n: Optional[int] = None, + index: Optional[Sequence[float]] = None, + data: Optional[Sequence[float]] = None, + method: str = "linear", + quantiles: Optional[Sequence[float]] = None, + round_method: Optional[str] = None, + max_labels: int = 10, + ) -> "StepColormap": """Splits the LinearColormap into a StepColormap. Parameters @@ -382,11 +398,7 @@ def to_step( max_ = max(data) min_ = min(data) scaled_cm = self.scale(vmin=min_, vmax=max_) - method = ( - "quantiles" - if quantiles is not None - else method if method is not None else "linear" - ) + method = "quantiles" if quantiles is not None else method if method.lower().startswith("lin"): if n is None: raise ValueError(msg) @@ -454,7 +466,12 @@ def to_step( tick_labels=self.tick_labels, ) - def scale(self, vmin=0.0, vmax=1.0, max_labels=10): + def scale( + self, + vmin: float = 0.0, + vmax: float = 1.0, + max_labels: int = 10, + ) -> "LinearColormap": """Transforms the colorscale so that the minimal and maximal values fit the given parameters. """ @@ -510,14 +527,14 @@ class StepColormap(ColorMap): def __init__( self, - colors, - index=None, - vmin=0.0, - vmax=1.0, - caption="", - text_color="black", - max_labels=10, - tick_labels=None, + colors: Sequence[TypeAnyColorType], + index: Optional[Sequence[float]] = None, + vmin: float = 0.0, + vmax: float = 1.0, + caption: str = "", + text_color: str = "black", + max_labels: int = 10, + tick_labels: Optional[Sequence[float]] = None, ): super().__init__( vmin=vmin, @@ -535,9 +552,9 @@ def __init__( self.index = [vmin + (vmax - vmin) * i * 1.0 / n for i in range(n + 1)] else: self.index = list(index) - self.colors = [_parse_color(x) for x in colors] + self.colors: List[TypeRGBAFloats] = [_parse_color(x) for x in colors] - def rgba_floats_tuple(self, x): + def rgba_floats_tuple(self, x: float) -> TypeRGBAFloats: """ Provides the color corresponding to value `x` in the form of a tuple (R,G,B,A) with float values between 0. and 1. @@ -549,9 +566,13 @@ def rgba_floats_tuple(self, x): return self.colors[-1] i = len([u for u in self.index if u <= x]) # 0 < i < n. - return tuple(self.colors[i - 1]) + return self.colors[i - 1] - def to_linear(self, index=None, max_labels=10): + def to_linear( + self, + index: Optional[Sequence[float]] = None, + max_labels: int = 10, + ) -> LinearColormap: """ Transforms the StepColormap into a LinearColormap. @@ -584,7 +605,12 @@ def to_linear(self, index=None, max_labels=10): max_labels=max_labels, ) - def scale(self, vmin=0.0, vmax=1.0, max_labels=10): + def scale( + self, + vmin: float = 0.0, + vmax: float = 1.0, + max_labels: int = 10, + ) -> "StepColormap": """Transforms the colorscale so that the minimal and maximal values fit the given parameters. """ @@ -611,7 +637,7 @@ def __init__(self): for key, val in _schemes.items(): setattr(self, key, LinearColormap(val)) - def _repr_html_(self): + def _repr_html_(self) -> str: return Template( """ @@ -634,7 +660,7 @@ def __init__(self): for key, val in _schemes.items(): setattr(self, key, StepColormap(val)) - def _repr_html_(self): + def _repr_html_(self) -> str: return Template( """
diff --git a/branca/element.py b/branca/element.py index f70bea6..242e921 100644 --- a/branca/element.py +++ b/branca/element.py @@ -14,11 +14,12 @@ from html import escape from os import urandom from pathlib import Path +from typing import BinaryIO, List, Optional, Tuple, Type, Union from urllib.request import urlopen from jinja2 import Environment, PackageLoader, Template -from .utilities import _camelify, _parse_size, none_max, none_min +from .utilities import TypeParseSize, _camelify, _parse_size, none_max, none_min ENV = Environment(loader=PackageLoader("branca", "templates")) @@ -45,19 +46,24 @@ class Element: """ - _template = Template( + _template: Template = Template( "{% for name, element in this._children.items() %}\n" " {{element.render(**kwargs)}}" "{% endfor %}", ) - def __init__(self, template=None, template_name=None): - self._name = "Element" + def __init__( + self, + template: Optional[str] = None, + template_name: Optional[str] = None, + ): + self._name: str = "Element" self._id = self._generate_id() - self._children = OrderedDict() - self._parent = None - self._template_str = template - self._template_name = template_name + self._id: str = hexlify(urandom(16)).decode() + self._children: OrderedDict[str, Element] = OrderedDict() + self._parent: Optional[Element] = None + self._template_str: Optional[str] = template + self._template_name: Optional[str] = template_name if template is not None: self._template = Template(template) @@ -65,10 +71,10 @@ def __init__(self, template=None, template_name=None): self._template = ENV.get_template(template_name) @classmethod - def _generate_id(cls): + def _generate_id(cls) -> str: return hexlify(urandom(16)).decode() - def __getstate__(self): + def __getstate__(self) -> dict: """Modify object state when pickling the object. jinja2 Templates cannot be pickled, so remove the instance attribute @@ -87,7 +93,7 @@ def __setstate__(self, state: dict): self.__dict__.update(state) - def get_name(self): + def get_name(self) -> str: """Returns a string representation of the object. This string has to be unique and to be a python and javascript-compatible @@ -95,13 +101,13 @@ def get_name(self): """ return _camelify(self._name) + "_" + self._id - def _get_self_bounds(self): + def _get_self_bounds(self) -> List[List[Optional[float]]]: """Computes the bounds of the object itself (not including it's children) in the form [[lat_min, lon_min], [lat_max, lon_max]] """ return [[None, None], [None, None]] - def get_bounds(self): + def get_bounds(self) -> List[List[Optional[float]]]: """Computes the bounds of the object and all it's children in the form [[lat_min, lon_min], [lat_max, lon_max]]. """ @@ -121,7 +127,12 @@ def get_bounds(self): ] return bounds - def add_children(self, child, name=None, index=None): + def add_children( + self, + child: "Element", + name: Optional[str] = None, + index: Optional[int] = None, + ) -> "Element": """Add a child.""" warnings.warn( "Method `add_children` is deprecated. Please use `add_child` instead.", @@ -130,7 +141,12 @@ def add_children(self, child, name=None, index=None): ) return self.add_child(child, name=name, index=index) - def add_child(self, child, name=None, index=None): + def add_child( + self, + child: "Element", + name: Optional[str] = None, + index: Optional[int] = None, + ) -> "Element": """Add a child.""" if name is None: name = child.get_name() @@ -143,13 +159,24 @@ def add_child(self, child, name=None, index=None): child._parent = self return self - def add_to(self, parent, name=None, index=None): + def add_to( + self, + parent: "Element", + name: Optional[str] = None, + index: Optional[int] = None, + ) -> "Element": """Add element to a parent.""" parent.add_child(self, name=name, index=index) return self - def to_dict(self, depth=-1, ordered=True, **kwargs): + def to_dict( + self, + depth: int = -1, + ordered: bool = True, + **kwargs, + ) -> Union[dict, OrderedDict]: """Returns a dict representation of the object.""" + dict_fun: Type[Union[dict, OrderedDict]] if ordered: dict_fun = OrderedDict else: @@ -163,25 +190,30 @@ def to_dict(self, depth=-1, ordered=True, **kwargs): (name, child.to_dict(depth=depth - 1)) for name, child in self._children.items() ], - ) # noqa + ) return out - def to_json(self, depth=-1, **kwargs): + def to_json(self, depth: int = -1, **kwargs) -> str: """Returns a JSON representation of the object.""" return json.dumps(self.to_dict(depth=depth, ordered=True), **kwargs) - def get_root(self): + def get_root(self) -> "Element": """Returns the root of the elements tree.""" if self._parent is None: return self else: return self._parent.get_root() - def render(self, **kwargs): + def render(self, **kwargs) -> str: """Renders the HTML representation of the element.""" return self._template.render(this=self, kwargs=kwargs) - def save(self, outfile, close_file=True, **kwargs): + def save( + self, + outfile: Union[str, bytes, Path, BinaryIO], + close_file: bool = True, + **kwargs, + ): """Saves an Element into a file. Parameters @@ -191,6 +223,7 @@ def save(self, outfile, close_file=True, **kwargs): close_file : bool, default True Whether the file has to be closed after write. """ + fid: BinaryIO if isinstance(outfile, (str, bytes, Path)): fid = open(outfile, "wb") else: @@ -206,15 +239,27 @@ def save(self, outfile, close_file=True, **kwargs): class Link(Element): """An abstract class for embedding a link in the HTML.""" - def get_code(self): + def __init__(self, url: str, download: bool = False): + super().__init__() + self.url = url + self.code: Optional[bytes] = None + if download: + self.get_code() + + def get_code(self) -> bytes: """Opens the link and returns the response's content.""" if self.code is None: self.code = urlopen(self.url).read() return self.code - def to_dict(self, depth=-1, **kwargs): + def to_dict( + self, + depth: int = -1, + ordered: bool = True, + **kwargs, + ) -> Union[dict, OrderedDict]: """Returns a dict representation of the object.""" - out = super().to_dict(depth=-1, **kwargs) + out = super().to_dict(depth=depth, ordered=ordered, **kwargs) out["url"] = self.url return out @@ -239,13 +284,9 @@ class JavascriptLink(Link): "{% endif %}", ) - def __init__(self, url, download=False): - super().__init__() + def __init__(self, url: str, download: bool = False): + super().__init__(url=url, download=download) self._name = "JavascriptLink" - self.url = url - self.code = None - if download: - self.get_code() class CssLink(Link): @@ -268,13 +309,9 @@ class CssLink(Link): "{% endif %}", ) - def __init__(self, url, download=False): - super().__init__() + def __init__(self, url: str, download: bool = False): + super().__init__(url=url, download=download) self._name = "CssLink" - self.url = url - self.code = None - if download: - self.get_code() class Figure(Element): @@ -318,11 +355,11 @@ class Figure(Element): def __init__( self, - width="100%", - height=None, - ratio="60%", - title=None, - figsize=None, + width: str = "100%", + height: Optional[str] = None, + ratio: str = "60%", + title: Optional[str] = None, + figsize: Optional[Tuple[int, int]] = None, ): super().__init__() self._name = "Figure" @@ -350,7 +387,12 @@ def __init__( name="meta_http", ) - def to_dict(self, depth=-1, **kwargs): + def to_dict( + self, + depth: int = -1, + ordered: bool = True, + **kwargs, + ) -> Union[dict, OrderedDict]: """Returns a dict representation of the object.""" out = super().to_dict(depth=depth, **kwargs) out["header"] = self.header.to_dict(depth=depth - 1, **kwargs) @@ -358,17 +400,17 @@ def to_dict(self, depth=-1, **kwargs): out["script"] = self.script.to_dict(depth=depth - 1, **kwargs) return out - def get_root(self): + def get_root(self) -> "Figure": """Returns the root of the elements tree.""" return self - def render(self, **kwargs): + def render(self, **kwargs) -> str: """Renders the HTML representation of the element.""" for name, child in self._children.items(): child.render(**kwargs) return self._template.render(this=self, kwargs=kwargs) - def _repr_html_(self, **kwargs): + def _repr_html_(self, **kwargs) -> str: """Displays the Figure in a Jupyter notebook.""" html = escape(self.render(**kwargs)) if self.height is None: @@ -391,7 +433,7 @@ def _repr_html_(self, **kwargs): ).format(html=html, width=self.width, height=self.height) return iframe - def add_subplot(self, x, y, n, margin=0.05): + def add_subplot(self, x: int, y: int, n: int, margin: float = 0.05) -> "Div": """Creates a div child subplot in a matplotlib.figure.add_subplot style. Parameters @@ -402,8 +444,11 @@ def add_subplot(self, x, y, n, margin=0.05): The number of columns in the grid. n : int The cell number in the grid, counted from 1 to x*y. + margin : float, default 0.05 + Factor to add to the left, top, width and height parameters. - Example: + Example + ------- >>> fig.add_subplot(3, 2, 5) # Create a div in the 5th cell of a 3rows x 2columns grid(bottom-left corner). @@ -451,9 +496,15 @@ class Html(Element): '
' # noqa "{% if this.script %}{{this.data}}{% else %}{{this.data|e}}{% endif %}
", - ) # noqa + ) - def __init__(self, data, script=False, width="100%", height="100%"): + def __init__( + self, + data: str, + script: bool = False, + width: TypeParseSize = "100%", + height: TypeParseSize = "100%", + ): super().__init__() self._name = "Html" self.script = script @@ -498,18 +549,18 @@ class Div(Figure): def __init__( self, - width="100%", - height="100%", - left="0%", - top="0%", - position="relative", + width: TypeParseSize = "100%", + height: TypeParseSize = "100%", + left: TypeParseSize = "0%", + top: TypeParseSize = "0%", + position: str = "relative", ): super(Figure, self).__init__() self._name = "Div" # Size Parameters. - self.width = _parse_size(width) - self.height = _parse_size(height) + self.width = _parse_size(width) # type: ignore + self.height = _parse_size(height) # type: ignore self.left = _parse_size(left) self.top = _parse_size(top) self.position = position @@ -526,7 +577,7 @@ def __init__( self.html._parent = self self.script._parent = self - def get_root(self): + def get_root(self) -> "Div": """Returns the root of the elements tree.""" return self @@ -558,14 +609,14 @@ def render(self, **kwargs): if script is not None: figure.script.add_child(Element(script(self, kwargs)), name=self.get_name()) - def _repr_html_(self, **kwargs): + def _repr_html_(self, **kwargs) -> str: """Displays the Div in a Jupyter notebook.""" if self._parent is None: self.add_to(Figure()) - out = self._parent._repr_html_(**kwargs) + out = self._parent._repr_html_(**kwargs) # type: ignore self._parent = None else: - out = self._parent._repr_html_(**kwargs) + out = self._parent._repr_html_(**kwargs) # type: ignore return out @@ -592,7 +643,14 @@ class IFrame(Element): width="600px", height="300px". """ - def __init__(self, html=None, width="100%", height=None, ratio="60%", figsize=None): + def __init__( + self, + html: Optional[Union[str, Element]] = None, + width: str = "100%", + height: Optional[str] = None, + ratio: str = "60%", + figsize: Optional[Tuple[int, int]] = None, + ): super().__init__() self._name = "IFrame" @@ -603,19 +661,17 @@ def __init__(self, html=None, width="100%", height=None, ratio="60%", figsize=No self.width = str(60 * figsize[0]) + "px" self.height = str(60 * figsize[1]) + "px" - if isinstance(html, str) or isinstance(html, bytes): + if isinstance(html, str): self.add_child(Element(html)) elif html is not None: self.add_child(html) - def render(self, **kwargs): + def render(self, **kwargs) -> str: """Renders the HTML representation of the element.""" html = super().render(**kwargs) html = "data:text/html;charset=utf-8;base64," + base64.b64encode( html.encode("utf8"), - ).decode( - "utf8", - ) # noqa + ).decode("utf8") if self.height is None: iframe = ( diff --git a/branca/utilities.py b/branca/utilities.py index 4bb3540..14a1d46 100644 --- a/branca/utilities.py +++ b/branca/utilities.py @@ -14,36 +14,43 @@ import struct import typing import zlib -from typing import Any, Callable, Union +from typing import Any, Callable, List, Optional, Sequence, Tuple, Union from jinja2 import Environment, PackageLoader try: import numpy as np except ImportError: - np = None + np = None # type: ignore if typing.TYPE_CHECKING: from branca.colormap import ColorMap -rootpath = os.path.abspath(os.path.dirname(__file__)) +rootpath: str = os.path.abspath(os.path.dirname(__file__)) -def get_templates(): +TypeParseSize = Union[int, float, str, Tuple[float, str]] + + +def get_templates() -> Environment: """Get Jinja templates.""" return Environment(loader=PackageLoader("branca", "templates")) -def legend_scaler(legend_values, max_labels=10.0): +def legend_scaler( + legend_values: Sequence[float], + max_labels: int = 10, +) -> List[Union[float, str]]: """ Downsamples the number of legend values so that there isn't a collision of text on the legend colorbar (within reason). The colorbar seems to support ~10 entries as a maximum. """ + legend_ticks: List[Union[float, str]] if len(legend_values) < max_labels: - legend_ticks = legend_values + legend_ticks = list(legend_values) else: spacer = int(math.ceil(len(legend_values) / max_labels)) legend_ticks = [] @@ -53,16 +60,11 @@ def legend_scaler(legend_values, max_labels=10.0): return legend_ticks -def linear_gradient(hexList, nColors): +def linear_gradient(hexList: List[str], nColors: int) -> List[str]: """ Given a list of hexcode values, will return a list of length nColors where the colors are linearly interpolated between the (r, g, b) tuples that are given. - - Examples - -------- - >>> linear_gradient([(0, 0, 0), (255, 0, 0), (255, 255, 0)], 100) - """ def _scale(start, finish, length, i): @@ -80,7 +82,7 @@ def _scale(start, finish, length, i): thex = "0" + thex return thex - allColors = [] + allColors: List[str] = [] # Separate (R, G, B) pairs. for start, end in zip(hexList[:-1], hexList[1:]): # Linearly interpolate between pair of hex ###### values and @@ -93,7 +95,7 @@ def _scale(start, finish, length, i): allColors.append("".join(["#", r, g, b])) # Pick only nColors colors from the total list. - result = [] + result: List[str] = [] for counter in range(nColors): fraction = float(counter) / (nColors - 1) index = int(fraction * (len(allColors) - 1)) @@ -101,7 +103,7 @@ def _scale(start, finish, length, i): return result -def color_brewer(color_code, n=6): +def color_brewer(color_code: str, n: int = 6) -> List[str]: """ Generate a colorbrewer color scheme of length 'len', type 'scheme. Live examples can be seen at http://colorbrewer2.org/ @@ -198,7 +200,11 @@ def color_brewer(color_code, n=6): return color_scheme -def image_to_url(image, colormap=None, origin="upper"): +def image_to_url( + image: Any, + colormap: Union["ColorMap", Callable, None] = None, + origin: str = "upper", +) -> str: """Infers the type of an image argument and transforms it into a URL. Parameters @@ -212,7 +218,7 @@ def image_to_url(image, colormap=None, origin="upper"): origin : ['upper' | 'lower'], optional, default 'upper' Place the [0, 0] index of the array in the upper left or lower left corner of the axes. - colormap : callable, used only for `mono` image. + colormap : ColorMap or callable, used only for `mono` image. Function of the form [x -> (r,g,b)] or [x -> (r,g,b,a)] for transforming a mono image into RGB. It must output iterables of length 3 or 4, with values between @@ -344,21 +350,17 @@ def png_pack(png_tag, data): ) -def _camelify(out): +def _camelify(out: str) -> str: return ( ( "".join( [ ( "_" + x.lower() - if i < len(out) - 1 - and x.isupper() - and out[i + 1].islower() # noqa + if i < len(out) - 1 and x.isupper() and out[i + 1].islower() else ( x.lower() + "_" - if i < len(out) - 1 - and x.islower() - and out[i + 1].isupper() # noqa + if i < len(out) - 1 and x.islower() and out[i + 1].isupper() else x.lower() ) ) @@ -368,10 +370,10 @@ def _camelify(out): ) .lstrip("_") .replace("__", "_") - ) # noqa + ) -def _parse_size(value): +def _parse_size(value: TypeParseSize) -> Tuple[float, str]: if isinstance(value, (int, float)): return float(value), "px" elif isinstance(value, str): @@ -421,7 +423,7 @@ def _locations_tolist(x): return x -def none_min(x, y): +def none_min(x: Optional[float], y: Optional[float]) -> Optional[float]: if x is None: return y elif y is None: @@ -430,7 +432,7 @@ def none_min(x, y): return min(x, y) -def none_max(x, y): +def none_max(x: Optional[float], y: Optional[float]) -> Optional[float]: if x is None: return y elif y is None: @@ -439,7 +441,7 @@ def none_max(x, y): return max(x, y) -def iter_points(x): +def iter_points(x: Union[List, Tuple]) -> list: """Iterates over a list representing a feature, and returns a list of points, whatever the shape of the array (Point, MultiPolyline, etc). """ diff --git a/pyproject.toml b/pyproject.toml index 97c7d5c..26a8a96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ [build-system] requires = ["setuptools>=41.2", "setuptools_scm"] build-backend = "setuptools.build_meta" + +[tool.mypy] +ignore_missing_imports = true diff --git a/requirements-dev.txt b/requirements-dev.txt index 549938d..3c3b55f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,6 +7,7 @@ flake8-mutable flake8-print isort jupyter +mypy nbsphinx nbval numpy From b96142da110ae8a93d5c17210aeaaafe284fc16f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 16:24:25 +0000 Subject: [PATCH 14/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/codespell-project/codespell: v2.2.6 → v2.3.0](https://github.com/codespell-project/codespell/compare/v2.2.6...v2.3.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 49159b4..a355e4e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: - id: blackdoc - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell args: From d75fb15c70a32a976b5a8d7cef5faa28a316d27b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:24:39 +0000 Subject: [PATCH 15/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.15.2 → v3.16.0](https://github.com/asottile/pyupgrade/compare/v3.15.2...v3.16.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a355e4e..c0160fe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,7 +44,7 @@ repos: - --ignore-words-list=thex - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 + rev: v3.16.0 hooks: - id: pyupgrade args: From bdf3545a15134848bdb02e6912e184e98cb526f5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:24:32 +0000 Subject: [PATCH 16/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/flake8: 7.0.0 → 7.1.0](https://github.com/PyCQA/flake8/compare/7.0.0...7.1.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c0160fe..844f699 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: files: requirements-dev.txt - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 + rev: 7.1.0 hooks: - id: flake8 exclude: docs/source/conf.py From a5ff2c701382f614d530420bd826e53c8d85a0f5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:24:42 +0000 Subject: [PATCH 17/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.16.0 → v3.17.0](https://github.com/asottile/pyupgrade/compare/v3.16.0...v3.17.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 844f699..9363f56 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,7 +44,7 @@ repos: - --ignore-words-list=thex - repo: https://github.com/asottile/pyupgrade - rev: v3.16.0 + rev: v3.17.0 hooks: - id: pyupgrade args: From d3aa6ecec1587483fe06f607fcb1210ef4f36591 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:24:49 +0000 Subject: [PATCH 18/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/flake8: 7.1.0 → 7.1.1](https://github.com/PyCQA/flake8/compare/7.1.0...7.1.1) - [github.com/psf/black: 24.4.2 → 24.8.0](https://github.com/psf/black/compare/24.4.2...24.8.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9363f56..efe373e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: files: requirements-dev.txt - repo: https://github.com/PyCQA/flake8 - rev: 7.1.0 + rev: 7.1.1 hooks: - id: flake8 exclude: docs/source/conf.py @@ -26,7 +26,7 @@ repos: args: ["--profile", "black", "--filter-files"] - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 24.8.0 hooks: - id: black language_version: python3 From e15b701b668aabe3382f08493abf940e401ac04e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:25:16 +0000 Subject: [PATCH 19/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v5.0.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index efe373e..09a03ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: check-ast From 050f4e6095a729a431c6343b4e3d3f7bfd1ad41f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:24:59 +0000 Subject: [PATCH 20/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.8.0 → 24.10.0](https://github.com/psf/black/compare/24.8.0...24.10.0) - [github.com/asottile/pyupgrade: v3.17.0 → v3.18.0](https://github.com/asottile/pyupgrade/compare/v3.17.0...v3.18.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 09a03ca..67bad13 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: args: ["--profile", "black", "--filter-files"] - repo: https://github.com/psf/black - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black language_version: python3 @@ -44,7 +44,7 @@ repos: - --ignore-words-list=thex - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + rev: v3.18.0 hooks: - id: pyupgrade args: From 974b4b5637818d5b2a64404840b40281809ad27f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 16:25:01 +0000 Subject: [PATCH 21/35] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.18.0 → v3.19.0](https://github.com/asottile/pyupgrade/compare/v3.18.0...v3.19.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 67bad13..c7e9b8e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,7 +44,7 @@ repos: - --ignore-words-list=thex - repo: https://github.com/asottile/pyupgrade - rev: v3.18.0 + rev: v3.19.0 hooks: - id: pyupgrade args: From fbd3366c8a7fb8298c7a7b03b503212bfc1e03c5 Mon Sep 17 00:00:00 2001 From: Ali Hamdan Date: Mon, 18 Nov 2024 13:47:29 +0100 Subject: [PATCH 22/35] Add py.typed file (#183) --- branca/py.typed | 0 setup.py | 1 + 2 files changed, 1 insertion(+) create mode 100644 branca/py.typed diff --git a/branca/py.typed b/branca/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py index 9abc069..4860cd9 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,7 @@ def walk_subpkg(name): "templates/*.html", "templates/*.js", "templates/*.txt", + "py.typed", ], } pkgs = ["branca"] From c6c49ddf054df3503b483af4a8ee2fc2bcc02ae6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:21:26 +0100 Subject: [PATCH 23/35] [pre-commit.ci] pre-commit autoupdate (#185) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.19.0 → v3.19.1](https://github.com/asottile/pyupgrade/compare/v3.19.0...v3.19.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c7e9b8e..9d462f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,7 +44,7 @@ repos: - --ignore-words-list=thex - repo: https://github.com/asottile/pyupgrade - rev: v3.19.0 + rev: v3.19.1 hooks: - id: pyupgrade args: From 0137319afe3b22a4b13306da97d2bbd465ce28ec Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 18:22:20 +0100 Subject: [PATCH 24/35] [pre-commit.ci] pre-commit autoupdate (#187) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/codespell-project/codespell: v2.3.0 → v2.4.0](https://github.com/codespell-project/codespell/compare/v2.3.0...v2.4.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9d462f9..ce538c9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: - id: blackdoc - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.0 hooks: - id: codespell args: From d0354e8cb2b5e79c3134efe77bf8528f4124c912 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 17:58:11 +0100 Subject: [PATCH 25/35] [pre-commit.ci] pre-commit autoupdate (#188) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/pycqa/isort: 5.13.2 → 6.0.0](https://github.com/pycqa/isort/compare/5.13.2...6.0.0) - [github.com/psf/black: 24.10.0 → 25.1.0](https://github.com/psf/black/compare/24.10.0...25.1.0) - [github.com/codespell-project/codespell: v2.4.0 → v2.4.1](https://github.com/codespell-project/codespell/compare/v2.4.0...v2.4.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- tests/test_colormap.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ce538c9..40f86ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,14 +19,14 @@ repos: args: [--max-line-length=105] - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 6.0.0 hooks: - id: isort additional_dependencies: [toml] args: ["--profile", "black", "--filter-files"] - repo: https://github.com/psf/black - rev: 24.10.0 + rev: 25.1.0 hooks: - id: black language_version: python3 @@ -37,7 +37,7 @@ repos: - id: blackdoc - repo: https://github.com/codespell-project/codespell - rev: v2.4.0 + rev: v2.4.1 hooks: - id: codespell args: diff --git a/tests/test_colormap.py b/tests/test_colormap.py index 09e757c..cd30405 100644 --- a/tests/test_colormap.py +++ b/tests/test_colormap.py @@ -1,4 +1,4 @@ -"""" +""" " Folium Colormap Module ---------------------- """ From 6a519e27774941d9f3aab1d34f244d594845778b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 17:46:30 +0100 Subject: [PATCH 26/35] [pre-commit.ci] pre-commit autoupdate (#189) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/flake8: 7.1.1 → 7.1.2](https://github.com/PyCQA/flake8/compare/7.1.1...7.1.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 40f86ac..45724b0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: files: requirements-dev.txt - repo: https://github.com/PyCQA/flake8 - rev: 7.1.1 + rev: 7.1.2 hooks: - id: flake8 exclude: docs/source/conf.py From a2626bbef83552520f0e5fdc23d937465cd81b6c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 18:32:10 +0100 Subject: [PATCH 27/35] [pre-commit.ci] pre-commit autoupdate (#191) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pycqa/isort: 6.0.0 → 6.0.1](https://github.com/pycqa/isort/compare/6.0.0...6.0.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 45724b0..5ea9204 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: args: [--max-line-length=105] - repo: https://github.com/pycqa/isort - rev: 6.0.0 + rev: 6.0.1 hooks: - id: isort additional_dependencies: [toml] From 5fcaf5518ab72dc0a0520dd8cf5b571e6aa81102 Mon Sep 17 00:00:00 2001 From: Frank Anema <33519926+Conengmo@users.noreply.github.com> Date: Sun, 16 Mar 2025 18:36:58 +0100 Subject: [PATCH 28/35] Pre-commit: disable autofix PR's, ignore E203,W503 (#194) * disable autofix prs * flake ignore E203,W503 --- .pre-commit-config.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5ea9204..90387b3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,5 @@ +ci: + autofix_prs: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 @@ -16,7 +18,7 @@ repos: hooks: - id: flake8 exclude: docs/source/conf.py - args: [--max-line-length=105] + args: [--max-line-length=105, "--ignore=E203,W503"] - repo: https://github.com/pycqa/isort rev: 6.0.1 From b47338d34f3a663f71d69efcf04202f07f73eb34 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 18:36:46 +0200 Subject: [PATCH 29/35] [pre-commit.ci] pre-commit autoupdate (#196) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/flake8: 7.1.2 → 7.2.0](https://github.com/PyCQA/flake8/compare/7.1.2...7.2.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 90387b3..63dd4d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: files: requirements-dev.txt - repo: https://github.com/PyCQA/flake8 - rev: 7.1.2 + rev: 7.2.0 hooks: - id: flake8 exclude: docs/source/conf.py From 283d47c34c402b2b7af45387dcf05e031384d21f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 13:50:07 -0300 Subject: [PATCH 30/35] [pre-commit.ci] pre-commit autoupdate (#197) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.19.1 → v3.20.0](https://github.com/asottile/pyupgrade/compare/v3.19.1...v3.20.0) - [github.com/asottile/add-trailing-comma: v3.1.0 → v3.2.0](https://github.com/asottile/add-trailing-comma/compare/v3.1.0...v3.2.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 63dd4d3..49425f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,13 +46,13 @@ repos: - --ignore-words-list=thex - repo: https://github.com/asottile/pyupgrade - rev: v3.19.1 + rev: v3.20.0 hooks: - id: pyupgrade args: - --py36-plus - repo: https://github.com/asottile/add-trailing-comma - rev: v3.1.0 + rev: v3.2.0 hooks: - id: add-trailing-comma From ad74740c74bb6486718671e3c6fc743be606d851 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:55:08 -0300 Subject: [PATCH 31/35] [pre-commit.ci] pre-commit autoupdate (#198) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/keewis/blackdoc: v0.3.9 → v0.4.0](https://github.com/keewis/blackdoc/compare/v0.3.9...v0.4.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 49425f4..59d945a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: language_version: python3 - repo: https://github.com/keewis/blackdoc - rev: v0.3.9 + rev: v0.4.0 hooks: - id: blackdoc From 9038f87e90a23669065d471588052f9800c74052 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 13:46:44 -0300 Subject: [PATCH 32/35] [pre-commit.ci] pre-commit autoupdate (#199) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/flake8: 7.2.0 → 7.3.0](https://github.com/PyCQA/flake8/compare/7.2.0...7.3.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 59d945a..12074fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: files: requirements-dev.txt - repo: https://github.com/PyCQA/flake8 - rev: 7.2.0 + rev: 7.3.0 hooks: - id: flake8 exclude: docs/source/conf.py From 470483e79e09ded7be14d29c930e2c7eeffb6aaf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 13:35:54 -0300 Subject: [PATCH 33/35] [pre-commit.ci] pre-commit autoupdate (#200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/keewis/blackdoc: v0.4.0 → v0.4.1](https://github.com/keewis/blackdoc/compare/v0.4.0...v0.4.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 12074fa..a49d0f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: language_version: python3 - repo: https://github.com/keewis/blackdoc - rev: v0.4.0 + rev: v0.4.1 hooks: - id: blackdoc From a9422c4f0c1e33625794e42883e9317ff204d577 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 13:50:57 -0300 Subject: [PATCH 34/35] [pre-commit.ci] pre-commit autoupdate (#201) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v5.0.0...v6.0.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a49d0f4..54b6c91 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ ci: autofix_prs: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: trailing-whitespace - id: check-ast From 6fb9a020d49527c0674236aa0d2e9728e493e941 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:48:52 -0300 Subject: [PATCH 35/35] [pre-commit.ci] pre-commit autoupdate (#202) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 25.1.0 → 25.9.0](https://github.com/psf/black/compare/25.1.0...25.9.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 54b6c91..22e7424 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: args: ["--profile", "black", "--filter-files"] - repo: https://github.com/psf/black - rev: 25.1.0 + rev: 25.9.0 hooks: - id: black language_version: python3