diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 53f16fb..4967ce6 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -54,3 +54,6 @@ de5e49b497cc8f5904637fa5d913e2f8b331f2e8 # Import `velofy.config` as `pkg_config` everywhere cf2534f41e9e535b8f68a38bb3e0ebadf3fb19b3 + +# Capitalize the explanations after "=>" +0090145b654c098cc464aed757e6c1fdda7487bd diff --git a/docs/conf.py b/docs/conf.py index 21bdfdb..674350a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,7 +5,7 @@ import velofy project = velofy.__pkg_name__ author = velofy.__author__ -copyright = f"2020, {author}" +project_copyright = f"2020, {author}" version = release = velofy.__version__ extensions = [ diff --git a/migrations/env.py b/migrations/env.py index 9613a00..1f95d8c 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -12,7 +12,8 @@ from velofy import db # Disable the --sql option, a.k.a, the "offline mode". if context.is_offline_mode(): - raise NotImplementedError("The --sql option is not implemented in this project") + msg = "The --sql option is not implemented in this project" + raise NotImplementedError(msg) # Set up the default Python logger from the alembic.ini file. @@ -21,14 +22,11 @@ log_config.fileConfig(context.config.config_file_name) def include_object(obj, _name, type_, _reflected, _compare_to): """Only include the clean schema into --autogenerate migrations.""" - if ( + return not ( type_ in {"table", "column"} - and hasattr(obj, "schema") # => fix for rare edge case + and hasattr(obj, "schema") # => Fix for rare edge case and obj.schema != pkg_config.CLEAN_SCHEMA - ): - return False - - return True + ) # Without a `pool`, the `connection` really closes after the migrations diff --git a/noxfile.py b/noxfile.py index 14897d5..f003d9c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -135,7 +135,7 @@ os.environ.setdefault("UV_PYTHON_PREFERENCE", "only-managed") # Where to keep temporary files (e.g., the constraints file in `install_pinned()`) tempfile.tempdir = ".cache/tmp" -os.makedirs(tempfile.tempdir, exist_ok=True) +pathlib.Path(tempfile.tempdir).mkdir(parents=True, exist_ok=True) @nox.session(name="format", python=MAIN_PYTHON) @@ -191,26 +191,40 @@ def lint_code(session: nox.Session) -> None: # because otherwise it treats missing packages as `Any` ".", "flake8", + "flake8-2020", "flake8-annotations", "flake8-bandit", "flake8-black", + "flake8-boolean-trap", "flake8-broken-line", "flake8-bugbear", + "flake8-builtins", "flake8-commas", "flake8-comprehensions", "flake8-debugger", "flake8-docstrings", + "flake8-errmsg", + "flake8-executable", + "flake8-implicit-str-concat", + "flake8-logging", + "flake8-pie", "flake8-pyproject", "flake8-pytest-style", "flake8-quotes", + "flake8-raise", + "flake8-return", "flake8-sfs", + "flake8-simplify", + "flake8-tidy-imports", "flake8-todos", "flake8-unused-arguments", "isort", "mypy", + "pandas-vet", "pep8-naming", "pydoclint[flake8]", "ruff", + "tryceratops", ) # Interpret extra arguments as `locations` of source files @@ -315,7 +329,7 @@ def build_docs(session: nox.Session) -> None: # Verify that all external links return 200 OK session.run("sphinx-build", "-b", "linkcheck", DOCS_LOCATION, DOCS_BUILD) - session.log(f"Docs are available at {os.getcwd()}/{DOCS_BUILD}index.html") + session.log(f"Docs are available at {pathlib.Path.cwd()}/{DOCS_BUILD}index.html") @nox.session(name="venv", python=MAIN_PYTHON, venv_backend="none") @@ -520,7 +534,7 @@ def clean_cwd(session: nox.Session) -> None: session.run("rm", "-rf", path) -def _expand(*patterns: str) -> cabc.Generator[pathlib.Path, None, None]: +def _expand(*patterns: str) -> cabc.Generator[pathlib.Path]: """Expand glob patterns into (resolved) paths. Args: @@ -552,7 +566,7 @@ def do_not_accept_arguments(session: nox.Session, *, raise_error: bool = True) - def do_not_reuse(session: nox.Session, *, raise_error: bool = True) -> None: """Do not reuse a session with the "-r" or "-R" flags.""" - if session._runner.venv._reused: + if session._runner.venv._reused: # noqa:SLF001 msg = 'be run without the "-r" and "-R" flags' if raise_error: @@ -640,10 +654,9 @@ def skip_install(session: nox.Session) -> bool: """ # Same logic to skip package installation as in core `nox` # See: https://github.com/wntrblm/nox/blob/2026.10.20/nox/sessions.py#L905 - venv = session._runner.venv - if session._runner.global_config.no_install and venv._reused: - return True - return False + no_install = session._runner.global_config.no_install # noqa:SLF001 + venv_reused = session._runner.venv._reused # noqa:SLF001 + return bool(no_install and venv_reused) if MAIN_PYTHON not in SUPPORTED_PYTHONS: diff --git a/pyproject.toml b/pyproject.toml index faa2744..10333eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -91,25 +91,39 @@ dev = [ # Code Analyzers "flake8 (>=7.5.0,<8.0.0)", + "flake8-2020 (>=1.8.1,<2.0.0)", "flake8-annotations (>=3.3.1,<4.0.0)", "flake8-bandit (>=4.1.1,<5.0.0)", "flake8-black (>=0.5.0,<0.6.0)", + "flake8-boolean-trap (>=1.0.1,<2.0.0)", "flake8-broken-line (>=1.0.0,<2.0.0)", "flake8-bugbear (>=26.11.22,<27.0.0)", + "flake8-builtins (>=3.2.0,<4.0.0)", "flake8-commas (>=4.0.0,<5.0.0)", "flake8-comprehensions (>=3.17.0,<4.0.0)", "flake8-debugger (>=4.1.2,<5.0.0)", "flake8-docstrings (>=1.7.0,<2.0.0)", + "flake8-errmsg (>=0.7.0,<0.8.0)", + "flake8-executable (>=2.1.3,<3.0.0)", + "flake8-implicit-str-concat (>=0.7.0,<0.8.0)", + "flake8-logging (>=1.8.0,<2.0.0)", + "flake8-pie (>=0.16.0,<0.17.0)", "flake8-pyproject (>=1.2.4,<2.0.0)", "flake8-pytest-style (>=2.2.0,<3.0.0)", "flake8-quotes (>=3.4.0,<4.0.0)", + "flake8-raise (>=0.0.5,<0.1.0)", + "flake8-return (>=1.2.0,<2.0.0)", "flake8-sfs (>=1.0.1,<2.0.0)", + "flake8-simplify (>=0.31.1,<0.32.0)", + "flake8-tidy-imports (>=4.12.0,<5.0.0)", "flake8-todos (>=0.3.1,<0.4.0)", "flake8-unused-arguments (>=0.0.14,<0.1.0)", "mypy (>=2.4.1,<3.0.0)", + "pandas-vet (>=2023.8.2)", "pep8-naming (>=0.15.1,<0.16.0)", "pydoclint[flake8] (>=0.12.0,<0.13.0)", "ruff (>=0.17.6,<0.18.0)", + "tryceratops (>=2.4.1,<3.0.0)", ] test = [ @@ -190,47 +204,110 @@ select = [ # ============= # flake8's base # ============= - # mccabe => cyclomatic complexity + # mccabe => Cyclomatic complexity "C901", # pycodestyle => PEP8 compliance "E", "W", - # pyflakes => basic errors + # pyflakes => Basic errors "F4", "F5", "F6", "F7", "F8", "F9", # ======= # plugins # ======= - # flake8-annotations => enforce type checking for functions + # flake8-2020 => Correct `sys.version` checks + "YTT", + # flake8-annotations => Enforce type checking for functions "ANN0", "ANN2", "ANN3", - # flake8-bandit => common security issues + # flake8-bandit => Common security issues "S1", "S2", "S3", "S4", "S5", "S6", "S7", - # flake8-black => complain if black would make changes + # flake8-black => Complain if black would make changes "BLK1", "BLK9", - # flake8-broken-line => no \ to end a line + # flake8-boolean-trap => Keyword-only flags + "FBT", + # flake8-broken-line => No \ to end a line "N400", - # flake8-bugbear => opinionated bugs and design flaws + # flake8-bugbear => Opinionated bugs and design flaws "B0", "B3", "B9", - # flake8-commas => better comma placements + # flake8-builtins => No shadowing of builtins + "A0", + # flake8-commas => Better comma placements "C8", - # flake8-comprehensions => better comprehensions + # flake8-comprehensions => Better comprehensions "C4", - # flake8-debugger => no debugger usage + # flake8-debugger => No debugger usage "T100", # flake8-docstrings => PEP257 compliance "D1", "D2", "D3", "D4", - # flake8-pytest-style => enforce a consistent style with pytest + # flake8-errmsg => Shorter tracebacks + "EM", + # flake8-executable => Consistent shebangs and executable bits + "EXE", + # flake8-implicit-str-concat => Unified string concatenation + "ISC", + # flake8-logging => Correct use of `logging` + "LOG", + # flake8-pie => No unnecessary constructs + "PIE", + # flake8-pytest-style => Enforce a consistent style with pytest "PT0", - # flake8-quotes => use double quotes everywhere (complying with black) + # flake8-quotes => Use double quotes everywhere (complying with black) "Q0", - # flake8-sfs => use f-strings as the only type of string formatting + # flake8-raise => No parentheses for exceptions without arguments + "R1", + # flake8-return => Consistent return statements + "R5", + # flake8-sfs => Use f-strings as the only type of string formatting "SFS", - # flake8-todos => unify TODOs + # flake8-simplify => Simpler code + "SIM", + # flake8-tidy-imports => No relative imports + "I25", + # flake8-todos => Unify TODOs "T00", - # flake8-unused-arguments => declared function arguments must be used + # flake8-unused-arguments => Declared function arguments must be used "U100", + # pandas-vet => Idiomatic `pandas` + "PD0", # pep8-naming => PEP8 naming conventions "N8", - # pydoclint => docstring matches implementation + # pydoclint => Docstring matches implementation "DOC", + # tryceratops => Clean exception handling + "TRY", + # ======================================== + # `ruff` only (no working `flake8` plugin) + # ======================================== + # flake8-blind-except => No blind `except Exception:` + # "BLE", + # eradicate => No commented-out code + # "ERA", + # flynt => F-strings instead of `str.join()` + # "FLY", + # refurb => Modern idioms + # "FURB", + # flake8-logging-format => Lazy `logging` messages + # "G", + # isort => Imports are sorted + # "I", + # flake8-import-conventions => Unified import aliases + # "ICN", + # NumPy-specific rules => Modern `numpy` APIs + # "NPY", + # Perflint => No performance anti-patterns + # "PERF", + # pygrep-hooks => Specific "# noqa" and "# type: ignore" comments + # "PGH", + # Pylint => Fewer bugs and simpler code + # "PL", + # flake8-use-pathlib => `pathlib` instead of `os` functions + # "PTH", + # Ruff-specific rules => Fewer bugs and cleaner code + # "RUF", + # flake8-self => No access to private members from outside + # "SLF", + # flake8-print => No `print()` + # "T20", + # pyupgrade => Modern syntax for the targeted Python version + # "UP", ] # By default, flake8 ignores some errors. @@ -240,19 +317,35 @@ ignore = [] # If --ignore is passed on the command # line, still ignore the following: extend-ignore = [ - # Too long line => duplicate with E501. + # `ruff`'s A003 does this better, as it only flags actual shadowing + "A003", + # Too long line => Duplicate with E501. "B950", # PEP 257 documents the arguments of `__init__()` in its own docstring. "DOC301", # Comply with black's style. # Source: https://github.com/psf/black/blob/master/docs/compatible_configs.md#flake8 "E203", "W503", + # `ruff`'s FBT003 does this better, as it allows builtins like `setattr()`. + "FBT003", + # Every `.add()` looks like `pandas` to this rule (`ruff` omits it). + "PD005", + # `len()` is needed for `pandas` objects, as their truth value is ambiguous. + "PIE787", # Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`. "PT023", + # `ruff`'s RET504 does this better, as it allows statements in between. + "R504", + # An `elif` after a `return` keeps a case distinction together. + "R505", # Allow f-strings as the only type of string formatting. "SFS301", + # `bool()` around a comparison can be deliberate (`ruff` omits this rule). + "SIM901", # TODOs need neither an author nor an issue. "T002", "T003", + # Messages are written where the exceptions are raised. + "TRY003", ] per-file-ignores = [ @@ -446,49 +539,108 @@ select = [ # =================================== # Violations also covered by `flake8` # =================================== - # flake8-annotations => enforce type checking for functions + # flake8-builtins => No shadowing of builtins + "A", + # flake8-annotations => Enforce type checking for functions "ANN0", "ANN2", - # flake8-unused-arguments ("U100") => declared function arguments must be used + # flake8-unused-arguments ("U100") => Declared function arguments must be used "ARG", - # flake8-bugbear => opinionated bugs and design flaws + # flake8-bugbear => Opinionated bugs and design flaws "B", - # flake8-comprehensions => better comprehensions + # flake8-comprehensions => Better comprehensions "C4", - # mccabe => cyclomatic complexity + # mccabe => Cyclomatic complexity "C90", - # flake8-commas ("C8") => better comma placements + # flake8-commas ("C8") => Better comma placements "COM", # flake8-docstrings => PEP257 compliance "D", # pycodestyle => PEP8 compliance "E", "W", - # pyflakes => basic errors + # flake8-errmsg => Shorter tracebacks + "EM", + # flake8-executable => Consistent shebangs and executable bits + "EXE", + # pyflakes => Basic errors "F", + # flake8-boolean-trap => Keyword-only flags + "FBT", + # flake8-implicit-str-concat => Unified string concatenation + "ISC", + # flake8-logging => Correct use of `logging` + "LOG", # pep8-naming => PEP8 naming conventions "N", - # flake8-pytest-style => enforce a consistent style with pytest + # pandas-vet => Idiomatic `pandas` + "PD", + # flake8-pie => No unnecessary constructs + "PIE", + # flake8-pytest-style => Enforce a consistent style with pytest "PT", - # flake8-quotes => use double quotes everywhere + # flake8-quotes => Use double quotes everywhere "Q", - # flake8-bandit => common security issues + # flake8-return ("R5") => Consistent return statements + "RET", + # flake8-raise ("R1") => No parentheses for exceptions without arguments + "RSE", + # flake8-bandit => Common security issues "S", - # flake8-debugger => no debugger usage + # flake8-simplify => Simpler code + "SIM", + # flake8-debugger => No debugger usage "T10", - # flake8-todos => unify TODOs + # flake8-todos => Unify TODOs "TD", + # flake8-tidy-imports ("I25") => No relative imports + "TID", + # tryceratops => Clean exception handling + "TRY", + # flake8-2020 => Correct `sys.version` checks + "YTT", # ======================================= # Violations not covered by `flake8` above # ======================================= - # eradicate => no commented-out code + # flake8-blind-except => No blind `except Exception:` + "BLE", + # eradicate => No commented-out code "ERA", + # flynt => F-strings instead of `str.join()` + "FLY", + # refurb => Modern idioms + "FURB", + # isort => Imports are sorted + "I", # flake8-import-conventions => Unified import aliases "ICN", - # isort => imports are sorted - "I", - # Pylint's refactoring rules => simpler and smaller functions - "PLR", - # flake8-print => no `print()` + # NumPy-specific rules => Modern `numpy` APIs + "NPY", + # Perflint => No performance anti-patterns + "PERF", + # pygrep-hooks => Specific "# noqa" and "# type: ignore" comments + "PGH", + # Pylint => Fewer bugs and simpler code + "PL", + # flake8-use-pathlib => `pathlib` instead of `os` functions + "PTH", + # Ruff-specific rules => Fewer bugs and cleaner code + "RUF", + # flake8-self => No access to private members from outside + "SLF", + # flake8-print => No `print()` "T20", + # pyupgrade => Modern syntax for the targeted Python version + "UP", + # ===================================== + # `flake8` only (no `ruff` counterpart) + # ===================================== + # flake8-black => Complain if black would make changes + # "BLK", + # pydoclint => Docstring matches implementation + # "DOC", + # flake8-broken-line => No \ to end a line + # "N400", + # flake8-sfs => Use f-strings as the only type of string formatting + # "SFS", ] extend-ignore = [ @@ -498,8 +650,21 @@ extend-ignore = [ "PLR2004", # Let's not do `@pytest.mark.no_cover()` instead of `@pytest.mark.no_cover`. "PT023", + # An `elif` after a `return` keeps a case distinction together. + "RET505", + # Some "# noqa" comments are only for `flake8`, which `ruff` cannot know. + "RUF100", # TODOs need neither an author nor an issue. "TD002", "TD003", + # Messages are written where the exceptions are raised. + "TRY003", +] + + +# Codes only `flake8` knows, kept in "# noqa" comments +external = [ + "B902", + "DOC", ] @@ -521,7 +686,8 @@ extend-ignore = [ # - PLR0913, PLR0917 => `pytest` passes fixtures as arguments. # - S101 => `assert` statements are ok in the test suite. # - S311 => The `random` module is not used for cryptography. -"tests/**/*.py" = ["ANN0", "ANN2", "D106", "PLR0913", "PLR0917", "S101", "S311"] +# - SLF001 => Tests may set up and inspect private members. +"tests/**/*.py" = ["ANN0", "ANN2", "D106", "PLR0913", "PLR0917", "S101", "S311", "SLF001"] [tool.ruff.lint.flake8-pytest-style] # aligned with [tool.flake8] above diff --git a/research/02_gridification.ipynb b/research/02_gridification.ipynb index 99e93e7..d2f6a2d 100644 --- a/research/02_gridification.ipynb +++ b/research/02_gridification.ipynb @@ -108,7 +108,7 @@ " -> created 38 pixels\n", "Creating grid with a side length of 1414 meters\n", " -> created 24 pixels\n", - "=> assigned 358 out of 48058 addresses in Lyon\n", + "=> Assigned 358 out of 48058 addresses in Lyon\n", "\n", "Creating grids for Paris\n", "Creating grid with a side length of 707 meters\n", @@ -117,7 +117,7 @@ " -> created 111 pixels\n", "Creating grid with a side length of 1414 meters\n", " -> created 66 pixels\n", - "=> assigned 1133 out of 108135 addresses in Paris\n", + "=> Assigned 1133 out of 108135 addresses in Paris\n", "\n", "Creating grids for Bordeaux\n", "Creating grid with a side length of 707 meters\n", @@ -126,7 +126,7 @@ " -> created 22 pixels\n", "Creating grid with a side length of 1414 meters\n", " -> created 15 pixels\n", - "=> assigned 123 out of 21742 addresses in Bordeaux\n" + "=> Assigned 123 out of 21742 addresses in Bordeaux\n" ] } ], diff --git a/scripts/get_update_info_for_dependencies.py b/scripts/get_update_info_for_dependencies.py index c9d2010..9ca926e 100755 --- a/scripts/get_update_info_for_dependencies.py +++ b/scripts/get_update_info_for_dependencies.py @@ -77,7 +77,7 @@ def get_years_since_release( latest_version = data["info"]["version"] release_date = infos_for_pinned_release[0]["upload_time"] - release_date = dt.datetime.fromisoformat(release_date.replace("Z", "+00:00")) + release_date = dt.datetime.fromisoformat(release_date) years_since_release = (dt.datetime.now() - release_date).days / 365.25 @@ -100,10 +100,7 @@ def make_comment( is_latest = pinned_version == latest_version - if is_latest: - comment = "up-to-date" - else: - comment = f"< {latest_version:<8}" + comment = "up-to-date" if is_latest else f"< {latest_version:<8}" if years_since_release > PKG_CONSIDERED_OLD: comment += f" {years_since_release} years ago" diff --git a/src/velofy/configuration.py b/src/velofy/configuration.py index 6dbdfa9..1660de8 100644 --- a/src/velofy/configuration.py +++ b/src/velofy/configuration.py @@ -40,19 +40,19 @@ class Config: # Side lengths (in meters) for which pixel grids are created. # They are the basis for the aggregated demand forecasts. - GRID_SIDE_LENGTHS = [707, 1000, 1414] + GRID_SIDE_LENGTHS = (707, 1000, 1414) # Time steps (in minutes) used to aggregate the # individual orders into time series. - TIME_STEPS = [60] + TIME_STEPS = (60,) # Training horizons (in full weeks) used to train the forecasting models. # For now, we only use 7 and 8 weeks as that was the best performing in # a previous study (note:4f79e8fa). - TRAIN_HORIZONS = [7, 8] + TRAIN_HORIZONS = (7, 8) # The demand forecasting methods used in the simulations. - FORECASTING_METHODS = ["hets", "rtarima"] + FORECASTING_METHODS = ("hets", "rtarima") # Colors for the visualizations ins `folium`. RESTAURANT_COLOR = "red" @@ -115,7 +115,8 @@ def make_config(env: str = "production") -> Config: elif env.strip().lower() == "testing": config = TestingConfig() else: - raise ValueError("Must be either 'production' or 'testing'") + msg = "Must be either 'production' or 'testing'" + raise ValueError(msg) # Without a PostgreSQL database the package cannot work. # As pytest sets the "TESTING" environment variable explicitly, diff --git a/src/velofy/console/forecasts.py b/src/velofy/console/forecasts.py index 0c9f98d..e4b3fb6 100644 --- a/src/velofy/console/forecasts.py +++ b/src/velofy/console/forecasts.py @@ -64,7 +64,7 @@ def tactical_heuristic( # noqa:C901,D417,DOC001 TIME_STEP: length of one time step in minutes; defaults to `60` TRAIN_HORIZON: length of the training horizon; defaults to `8` - """ # noqa:D412,D417 => formatted as `click` help text + """ # noqa:D412,D417 => Formatted as `click` help text # Input validation. try: @@ -90,8 +90,8 @@ def tactical_heuristic( # noqa:C901,D417,DOC001 click.echo( "Parameters: " - + f"city={city}, grid.side_length={side_length}, " - + f"time_step={time_step}, train_horizon={train_horizon}", + f"city={city}, grid.side_length={side_length}, " + f"time_step={time_step}, train_horizon={train_horizon}", ) # Load the historic order data. @@ -132,7 +132,7 @@ def tactical_heuristic( # noqa:C901,D417,DOC001 ) click.echo( f"Predicting pixel #{pixel.id} in {city} " - + f"for {predict_day} with {model.name}", + f"for {predict_day} with {model.name}", ) # Only loop over the time steps corresponding to working hours. diff --git a/src/velofy/console/gridify.py b/src/velofy/console/gridify.py index 4c82842..9cc0591 100644 --- a/src/velofy/console/gridify.py +++ b/src/velofy/console/gridify.py @@ -42,7 +42,7 @@ def gridify() -> None: # pragma: no cover note:b1f68d24 .count() ) click.echo( - f"=> assigned {n_assigned} out of {len(city.addresses)} addresses in {city.name}", # noqa:E501 + f"=> Assigned {n_assigned} out of {len(city.addresses)} addresses in {city.name}", # noqa:E501 ) db.session.commit() diff --git a/src/velofy/console/main.py b/src/velofy/console/main.py index 8446905..0c7dac5 100644 --- a/src/velofy/console/main.py +++ b/src/velofy/console/main.py @@ -8,7 +8,12 @@ from click import core as cli_core import velofy -def show_version(ctx: cli_core.Context, _param: t.Any, value: bool) -> None: +def show_version( + ctx: cli_core.Context, + _param: t.Any, + # `click` passes all arguments to callbacks positionally + value: bool, # noqa:FBT001 +) -> None: """Show the package's version.""" # If --version / -V is NOT passed in, # continue with the command. diff --git a/src/velofy/db/addresses_addresses.py b/src/velofy/db/addresses_addresses.py index 1aeb4da..9defe93 100644 --- a/src/velofy/db/addresses_addresses.py +++ b/src/velofy/db/addresses_addresses.py @@ -147,9 +147,9 @@ class Path(meta.Base): paths = [] # We consider all 2-tuples of `Address`es. The symmetric graph is ... - for first, second in itertools.combinations(addresses, 2): + for pair in itertools.combinations(addresses, 2): # ... implicitly enforced by a precedence constraint for the `.id`s. - first, second = (first, second) if first.id < second.id else (second, first) + first, second = sorted(pair, key=lambda address: address.id) # If there is no `Path` object in the database ... path = ( @@ -183,7 +183,7 @@ class Path(meta.Base): return paths @classmethod - def from_order(cls, order: db.Order, google_maps: bool = False) -> Path: + def from_order(cls, order: db.Order, *, google_maps: bool = False) -> Path: """Calculate the path for an `Order` object. The path goes from the `Order.pickup_address` to the `Order.delivery_address`. @@ -270,7 +270,8 @@ class Path(meta.Base): underlying attributes (i.e., `._directions`) are to be changed. """ if not self._directions: - raise RuntimeError("_directions is not set") + msg = "_directions is not set" + raise RuntimeError(msg) points = [utils.Location(*point) for point in json.loads(self._directions)] for point in points: diff --git a/src/velofy/db/cities.py b/src/velofy/db/cities.py index 258add4..a6fc363 100644 --- a/src/velofy/db/cities.py +++ b/src/velofy/db/cities.py @@ -149,6 +149,7 @@ class City(meta.Base): def draw_restaurants( self, + *, order_counts: bool = False, # pragma: no cover ) -> folium.Map: """Draw all restaurants on the`.map`. diff --git a/src/velofy/db/customers.py b/src/velofy/db/customers.py index b047b24..b7b146c 100644 --- a/src/velofy/db/customers.py +++ b/src/velofy/db/customers.py @@ -46,6 +46,7 @@ class Customer(meta.Base): def draw( # noqa:C901,PLR0912 self, + *, restaurants: bool = True, order_counts: bool = False, # pragma: no cover ) -> folium.Map: diff --git a/src/velofy/db/forecasts.py b/src/velofy/db/forecasts.py index 45717e8..a602f5b 100644 --- a/src/velofy/db/forecasts.py +++ b/src/velofy/db/forecasts.py @@ -232,25 +232,13 @@ class Forecast(meta.Base): low95 = data.loc[timestamp_idx, "low95"] high95 = data.loc[timestamp_idx, "high95"] - if math.isnan(low80): - low80 = None - else: - low80 = float(round(low80, 5)) + low80 = None if math.isnan(low80) else float(round(low80, 5)) - if math.isnan(high80): - high80 = None - else: - high80 = float(round(high80, 5)) + high80 = None if math.isnan(high80) else float(round(high80, 5)) - if math.isnan(low95): - low95 = None - else: - low95 = float(round(low95, 5)) + low95 = None if math.isnan(low95) else float(round(low95, 5)) - if math.isnan(high95): - high95 = None - else: - high95 = float(round(high95, 5)) + high95 = None if math.isnan(high95) else float(round(high95, 5)) forecasts.append( cls( diff --git a/src/velofy/db/orders.py b/src/velofy/db/orders.py index 91c66ff..00b6cba 100644 --- a/src/velofy/db/orders.py +++ b/src/velofy/db/orders.py @@ -528,7 +528,7 @@ class Order(meta.Base): def corrected(self) -> bool: """If any timestamp was corrected as compared to the original data.""" return bool( - self.scheduled_delivery_at_corrected # => too much logic + self.scheduled_delivery_at_corrected # => Too much logic or self.cancelled_at_corrected or self.restaurant_notified_at_corrected or self.restaurant_confirmed_at_corrected @@ -549,9 +549,11 @@ class Order(meta.Base): This measures the time it took the UDP to notify the `.courier` after dispatch. """ if not self.dispatch_at: - raise RuntimeError("dispatch_at is not set") + msg = "dispatch_at is not set" + raise RuntimeError(msg) if not self.courier_accepted_at: - raise RuntimeError("courier_accepted_at is not set") + msg = "courier_accepted_at is not set" + raise RuntimeError(msg) return self.courier_accepted_at - self.dispatch_at @property @@ -561,36 +563,44 @@ class Order(meta.Base): A subset of `.time_to_accept`. """ if not self.courier_notified_at: - raise RuntimeError("courier_notified_at is not set") + msg = "courier_notified_at is not set" + raise RuntimeError(msg) if not self.courier_accepted_at: - raise RuntimeError("courier_accepted_at is not set") + msg = "courier_accepted_at is not set" + raise RuntimeError(msg) return self.courier_accepted_at - self.courier_notified_at @property def time_to_pickup(self) -> dt.timedelta: """Time from the `.courier`'s acceptance to arrival at `.pickup_address`.""" if not self.courier_accepted_at: - raise RuntimeError("courier_accepted_at is not set") + msg = "courier_accepted_at is not set" + raise RuntimeError(msg) if not self.reached_pickup_at: - raise RuntimeError("reached_pickup_at is not set") + msg = "reached_pickup_at is not set" + raise RuntimeError(msg) return self.reached_pickup_at - self.courier_accepted_at @property def time_at_pickup(self) -> dt.timedelta: """Time the `.courier` stayed at the `.pickup_address`.""" if not self.reached_pickup_at: - raise RuntimeError("reached_pickup_at is not set") + msg = "reached_pickup_at is not set" + raise RuntimeError(msg) if not self.pickup_at: - raise RuntimeError("pickup_at is not set") + msg = "pickup_at is not set" + raise RuntimeError(msg) return self.pickup_at - self.reached_pickup_at @property def scheduled_pickup_at(self) -> dt.datetime: """Point in time at which the pickup was scheduled.""" if not self.restaurant_notified_at: - raise RuntimeError("restaurant_notified_at is not set") + msg = "restaurant_notified_at is not set" + raise RuntimeError(msg) if not self.estimated_prep_duration: - raise RuntimeError("estimated_prep_duration is not set") + msg = "estimated_prep_duration is not set" + raise RuntimeError(msg) delta = dt.timedelta(seconds=self.estimated_prep_duration) return self.restaurant_notified_at + delta @@ -605,7 +615,8 @@ class Order(meta.Base): Goes together with `.courier_late`. """ if not self.reached_pickup_at: - raise RuntimeError("reached_pickup_at is not set") + msg = "reached_pickup_at is not set" + raise RuntimeError(msg) return max( dt.timedelta(), @@ -623,7 +634,8 @@ class Order(meta.Base): Goes together with `.courier_early`. """ if not self.reached_pickup_at: - raise RuntimeError("reached_pickup_at is not set") + msg = "reached_pickup_at is not set" + raise RuntimeError(msg) return max( dt.timedelta(), @@ -641,7 +653,8 @@ class Order(meta.Base): Goes together with `.restaurant_late`. """ if not self.pickup_at: - raise RuntimeError("pickup_at is not set") + msg = "pickup_at is not set" + raise RuntimeError(msg) return max(dt.timedelta(), self.scheduled_pickup_at - self.pickup_at) @@ -656,7 +669,8 @@ class Order(meta.Base): Goes together with `.restaurant_early`. """ if not self.pickup_at: - raise RuntimeError("pickup_at is not set") + msg = "pickup_at is not set" + raise RuntimeError(msg) return max(dt.timedelta(), self.pickup_at - self.scheduled_pickup_at) @@ -664,18 +678,22 @@ class Order(meta.Base): def time_to_delivery(self) -> dt.timedelta: """Time the `.courier` took from `.pickup_address` to `.delivery_address`.""" if not self.pickup_at: - raise RuntimeError("pickup_at is not set") + msg = "pickup_at is not set" + raise RuntimeError(msg) if not self.reached_delivery_at: - raise RuntimeError("reached_delivery_at is not set") + msg = "reached_delivery_at is not set" + raise RuntimeError(msg) return self.reached_delivery_at - self.pickup_at @property def time_at_delivery(self) -> dt.timedelta: """Time the `.courier` stayed at the `.delivery_address`.""" if not self.reached_delivery_at: - raise RuntimeError("reached_delivery_at is not set") + msg = "reached_delivery_at is not set" + raise RuntimeError(msg) if not self.delivery_at: - raise RuntimeError("delivery_at is not set") + msg = "delivery_at is not set" + raise RuntimeError(msg) return self.delivery_at - self.reached_delivery_at @property @@ -696,11 +714,14 @@ class Order(meta.Base): Goes together with `.delivery_late`. """ if not self.scheduled: - raise AttributeError("Makes sense only for scheduled orders") + msg = "Makes sense only for scheduled orders" + raise AttributeError(msg) if not self.scheduled_delivery_at: - raise RuntimeError("scheduled_delivery_at is not set") + msg = "scheduled_delivery_at is not set" + raise RuntimeError(msg) if not self.delivery_at: - raise RuntimeError("delivery_at is not set") + msg = "delivery_at is not set" + raise RuntimeError(msg) return max(dt.timedelta(), self.scheduled_delivery_at - self.delivery_at) @property @@ -714,22 +735,28 @@ class Order(meta.Base): Goes together with `.delivery_early`. """ if not self.scheduled: - raise AttributeError("Makes sense only for scheduled orders") + msg = "Makes sense only for scheduled orders" + raise AttributeError(msg) if not self.scheduled_delivery_at: - raise RuntimeError("scheduled_delivery_at is not set") + msg = "scheduled_delivery_at is not set" + raise RuntimeError(msg) if not self.delivery_at: - raise RuntimeError("delivery_at is not set") + msg = "delivery_at is not set" + raise RuntimeError(msg) return max(dt.timedelta(), self.delivery_at - self.scheduled_delivery_at) @property def total_time(self) -> dt.timedelta: """Time from order placement to delivery for an `.ad_hoc` order.""" if self.scheduled: - raise AttributeError("Scheduled orders have no total_time") + msg = "Scheduled orders have no total_time" + raise AttributeError(msg) if self.cancelled: - raise RuntimeError("Cancelled orders have no total_time") + msg = "Cancelled orders have no total_time" + raise RuntimeError(msg) if not self.delivery_at: - raise RuntimeError("delivery_at is not set") + msg = "delivery_at is not set" + raise RuntimeError(msg) return self.delivery_at - self.placed_at # Other Methods diff --git a/src/velofy/db/pixels.py b/src/velofy/db/pixels.py index 8c1b57b..61c5ecf 100644 --- a/src/velofy/db/pixels.py +++ b/src/velofy/db/pixels.py @@ -156,8 +156,9 @@ class Pixel(meta.Base): """Shortcut to the `.city.map` object.""" return self.grid.city.map - def draw( # noqa:C901,PLR0912 + def draw( self, + *, restaurants: bool = True, order_counts: bool = False, # pragma: no cover ) -> folium.Map: @@ -177,10 +178,7 @@ class Pixel(meta.Base): info_text = f"Pixel({self.n_x}|{self.n_y})" # Make the `Pixel`s look like a checkerboard. - if (self.n_x + self.n_y) % 2: - color = "#808000" - else: - color = "#ff8c00" + color = "#808000" if (self.n_x + self.n_y) % 2 else "#ff8c00" marker = folium.Rectangle( bounds=bounds, diff --git a/src/velofy/db/restaurants.py b/src/velofy/db/restaurants.py index bd4c467..73bb101 100644 --- a/src/velofy/db/restaurants.py +++ b/src/velofy/db/restaurants.py @@ -91,6 +91,7 @@ class Restaurant(meta.Base): def draw( self, + *, customers: bool = True, order_counts: bool = False, # pragma: no cover ) -> folium.Map: diff --git a/src/velofy/db/utils/colors.py b/src/velofy/db/utils/colors.py index 89ba6b3..c081fe9 100644 --- a/src/velofy/db/utils/colors.py +++ b/src/velofy/db/utils/colors.py @@ -8,6 +8,7 @@ from matplotlib import colors def make_random_cmap( n_colors: int, + *, bright: bool = True, # pragma: no cover ) -> colors.LinearSegmentedColormap: """Create a random `Colormap` with `n_colors` different colors. @@ -19,21 +20,19 @@ def make_random_cmap( Returns: colormap """ - np.random.seed(42) + rng = np.random.default_rng(42) if bright: hsv_colors = [ ( - np.random.uniform(low=0.0, high=1), - np.random.uniform(low=0.2, high=1), - np.random.uniform(low=0.9, high=1), + rng.uniform(low=0.0, high=1), + rng.uniform(low=0.2, high=1), + rng.uniform(low=0.9, high=1), ) for _ in range(n_colors) ] - rgb_colors = [] - for color in hsv_colors: - rgb_colors.append(colorsys.hsv_to_rgb(*color)) + rgb_colors = [colorsys.hsv_to_rgb(*color) for color in hsv_colors] else: low = 0.0 @@ -41,9 +40,9 @@ def make_random_cmap( rgb_colors = [ ( - np.random.uniform(low=low, high=high), - np.random.uniform(low=low, high=high), - np.random.uniform(low=low, high=high), + rng.uniform(low=low, high=high), + rng.uniform(low=low, high=high), + rng.uniform(low=low, high=high), ) for _ in range(n_colors) ] diff --git a/src/velofy/db/utils/locations.py b/src/velofy/db/utils/locations.py index df7ef6b..309f57d 100644 --- a/src/velofy/db/utils/locations.py +++ b/src/velofy/db/utils/locations.py @@ -94,13 +94,17 @@ class Location: """The UTM zone of the location as the zone number and the band.""" return self._zone, self._band + # Explicitly unhashable, the default for classes defining only `__eq__()` + __hash__ = None # type: ignore[assignment] + def __eq__(self, other: object) -> bool: """Check if two `Location` objects are the same location.""" if not isinstance(other, Location): return NotImplemented if self.zone != other.zone: - raise ValueError("locations must be in the same zone, including the band") + msg = "locations must be in the same zone, including the band" + raise ValueError(msg) return (self.easting, self.northing) == (other.easting, other.northing) @@ -111,7 +115,8 @@ class Location: The origin, which defines the `(0, 0)` coordinate, is set with `.relate_to()`. """ if self._normalized_easting is None: - raise RuntimeError("an origin to relate to must be set first") + msg = "an origin to relate to must be set first" + raise RuntimeError(msg) return self._normalized_easting @@ -122,7 +127,8 @@ class Location: The origin, which defines the `(0, 0)` coordinate, is set with `.relate_to()`. """ if self._normalized_northing is None: - raise RuntimeError("an origin to relate to must be set first") + msg = "an origin to relate to must be set first" + raise RuntimeError(msg) return self._normalized_northing @@ -137,13 +143,16 @@ class Location: properties, the `other` origin may only be set once! """ if self._normalized_easting is not None: - raise RuntimeError("the `other` origin may only be set once") + msg = "the `other` origin may only be set once" + raise RuntimeError(msg) if not isinstance(other, Location): - raise TypeError("`other` is not a `Location` object") + msg = "`other` is not a `Location` object" + raise TypeError(msg) if self.zone != other.zone: - raise ValueError("`other` must be in the same zone, including the band") + msg = "`other` must be in the same zone, including the band" + raise ValueError(msg) self._normalized_easting = self.easting - other.easting self._normalized_northing = self.northing - other.northing diff --git a/src/velofy/forecasts/methods/arima.py b/src/velofy/forecasts/methods/arima.py index 7aa88f6..9391063 100644 --- a/src/velofy/forecasts/methods/arima.py +++ b/src/velofy/forecasts/methods/arima.py @@ -33,13 +33,14 @@ def predict( """ # Initialize R only if it is actually used. # For example, the nox session "ci-tests-fast" does not use it. - from velofy import init_r # noqa:F401 + from velofy import init_r # noqa:F401,PLC0415 # Re-seed R every time it is used to ensure reproducibility. robjects.r("set.seed(42)") - if training_ts.isnull().any(): - raise ValueError("`training_ts` must not contain `NaN` values") + if training_ts.isna().any(): + msg = "`training_ts` must not contain `NaN` values" + raise ValueError(msg) # Copy the data from Python to R. robjects.globalenv["data"] = robjects.r["ts"]( @@ -47,7 +48,7 @@ def predict( frequency=frequency, ) - seasonal = "TRUE" if bool(seasonal_fit) else "FALSE" + seasonal = "TRUE" if seasonal_fit else "FALSE" n_steps_ahead = len(forecast_interval) # Make the predictions in R. diff --git a/src/velofy/forecasts/methods/decomposition.py b/src/velofy/forecasts/methods/decomposition.py index b77934f..85099b0 100644 --- a/src/velofy/forecasts/methods/decomposition.py +++ b/src/velofy/forecasts/methods/decomposition.py @@ -93,70 +93,79 @@ def stl( # noqa:C901,PLR0912,PLR0913,PLR0915 """ # Validate all arguments and set default values. - if time_series.isnull().any(): - raise ValueError("`time_series` must not contain `NaN` values") + if time_series.isna().any(): + msg = "`time_series` must not contain `NaN` values" + raise ValueError(msg) if ns % 2 == 0 or ns < 7: - raise ValueError("`ns` must be odd and `>= 7`") + msg = "`ns` must be odd and `>= 7`" + raise ValueError(msg) default_nt = math.ceil((1.5 * frequency) / (1 - (1.5 / ns))) if nt is not None: if nt % 2 == 0 or nt < default_nt: - raise ValueError( + msg = ( "`nt` must be odd and `>= (1.5 * frequency) / [1 - (1.5 / ns)]`, " - + f"which is {default_nt}", + f"which is {default_nt}" ) + raise ValueError(msg) else: nt = default_nt - if nt % 2 == 0: # pragma: no cover => hard to construct edge case + if nt % 2 == 0: # pragma: no cover => Hard to construct edge case nt += 1 if nl is not None: if nl % 2 == 0 or nl < frequency: - raise ValueError("`nl` must be odd and `>= frequency`") + msg = "`nl` must be odd and `>= frequency`" + raise ValueError(msg) elif frequency % 2 == 0: nl = frequency + 1 - else: # pragma: no cover => hard to construct edge case + else: # pragma: no cover => Hard to construct edge case nl = frequency if ds not in {0, 1}: - raise ValueError("`ds` must be either `0` or `1`") + msg = "`ds` must be either `0` or `1`" + raise ValueError(msg) if dt not in {0, 1}: - raise ValueError("`dt` must be either `0` or `1`") + msg = "`dt` must be either `0` or `1`" + raise ValueError(msg) if dl not in {0, 1}: - raise ValueError("`dl` must be either `0` or `1`") + msg = "`dl` must be either `0` or `1`" + raise ValueError(msg) if js is not None: if js <= 0: - raise ValueError("`js` must be positive") + msg = "`js` must be positive" + raise ValueError(msg) else: js = math.ceil(ns / 10) if jt is not None: if jt <= 0: - raise ValueError("`jt` must be positive") + msg = "`jt` must be positive" + raise ValueError(msg) else: jt = math.ceil(nt / 10) if jl is not None: if jl <= 0: - raise ValueError("`jl` must be positive") + msg = "`jl` must be positive" + raise ValueError(msg) else: jl = math.ceil(nl / 10) if ni <= 0: - raise ValueError("`ni` must be positive") + msg = "`ni` must be positive" + raise ValueError(msg) if no < 0: - raise ValueError("`no` must be non-negative") - elif no > 0: - robust = True - else: - robust = False + msg = "`no` must be non-negative" + raise ValueError(msg) + robust = no > 0 # Initialize R only if it is actually used. # For example, the nox session "ci-tests-fast" does not use it. - from velofy import init_r # noqa:F401 + from velofy import init_r # noqa:F401,PLC0415 # Re-seed R every time it is used to ensure reproducibility. robjects.r("set.seed(42)") diff --git a/src/velofy/forecasts/methods/ets.py b/src/velofy/forecasts/methods/ets.py index 39c443a..58a11ad 100644 --- a/src/velofy/forecasts/methods/ets.py +++ b/src/velofy/forecasts/methods/ets.py @@ -34,13 +34,14 @@ def predict( """ # Initialize R only if it is actually used. # For example, the nox session "ci-tests-fast" does not use it. - from velofy import init_r # noqa:F401 + from velofy import init_r # noqa:F401,PLC0415 # Re-seed R every time it is used to ensure reproducibility. robjects.r("set.seed(42)") - if training_ts.isnull().any(): - raise ValueError("`training_ts` must not contain `NaN` values") + if training_ts.isna().any(): + msg = "`training_ts` must not contain `NaN` values" + raise ValueError(msg) # Copy the data from Python to R. robjects.globalenv["data"] = robjects.r["ts"]( @@ -48,7 +49,7 @@ def predict( frequency=frequency, ) - model = "ZZZ" if bool(seasonal_fit) else "ZZN" + model = "ZZZ" if seasonal_fit else "ZZN" n_steps_ahead = len(forecast_interval) # Make the predictions in R. diff --git a/src/velofy/forecasts/methods/extrapolate_season.py b/src/velofy/forecasts/methods/extrapolate_season.py index 7d70af7..021a413 100644 --- a/src/velofy/forecasts/methods/extrapolate_season.py +++ b/src/velofy/forecasts/methods/extrapolate_season.py @@ -36,8 +36,9 @@ def predict( ValueError: if `training_ts` contains `NaN` values or some predictions could not be made for time steps in the `forecast_interval` """ - if training_ts.isnull().any(): - raise ValueError("`training_ts` must not contain `NaN` values") + if training_ts.isna().any(): + msg = "`training_ts` must not contain `NaN` values" + raise ValueError(msg) extrapolated_ts = pd.Series(index=forecast_interval, dtype=float) seasonal_lag = frequency * (training_ts.index[1] - training_ts.index[0]) @@ -60,8 +61,9 @@ def predict( idx += seasonal_lag # Sanity check. - if extrapolated_ts.isnull().any(): # pragma: no cover - raise ValueError("missing predictions in the `forecast_interval`") + if extrapolated_ts.isna().any(): # pragma: no cover + msg = "missing predictions in the `forecast_interval`" + raise ValueError(msg) return pd.DataFrame( data={ diff --git a/src/velofy/forecasts/models/base.py b/src/velofy/forecasts/models/base.py index 2b60b85..723172f 100644 --- a/src/velofy/forecasts/models/base.py +++ b/src/velofy/forecasts/models/base.py @@ -118,6 +118,7 @@ class ForecastingModelABC(abc.ABC): return forecast # ..., however, we put in a loud error, just in case. - raise RuntimeError( # pragma: no cover - "`Forecast` for `predict_at` was not returned by `*Model.predict()`", + msg = ( # pragma: no cover + "`Forecast` for `predict_at` was not returned by `*Model.predict()`" ) + raise RuntimeError(msg) # pragma: no cover diff --git a/src/velofy/forecasts/models/tactical/horizontal.py b/src/velofy/forecasts/models/tactical/horizontal.py index 5d461a4..4d262d2 100644 --- a/src/velofy/forecasts/models/tactical/horizontal.py +++ b/src/velofy/forecasts/models/tactical/horizontal.py @@ -52,7 +52,8 @@ class HorizontalETSModel(base.ForecastingModelABC): # Sanity check. if frequency != 7: # pragma: no cover - raise RuntimeError("`frequency` should be `7`") + msg = "`frequency` should be `7`" + raise RuntimeError(msg) # Make `predictions` with the seasonal ETS method ("ZZZ" model). predictions = methods.ets.predict( @@ -65,10 +66,12 @@ class HorizontalETSModel(base.ForecastingModelABC): predictions.insert(loc=0, column="actual", value=actuals_ts) # Sanity checks. - if predictions.isnull().sum().any(): # pragma: no cover - raise RuntimeError("missing predictions in hets model") + if predictions.isna().sum().any(): # pragma: no cover + msg = "missing predictions in hets model" + raise RuntimeError(msg) if predict_at not in predictions.index: # pragma: no cover - raise RuntimeError("missing prediction for `predict_at`") + msg = "missing prediction for `predict_at`" + raise RuntimeError(msg) return predictions @@ -109,11 +112,11 @@ class HorizontalSMAModel(base.ForecastingModelABC): # Sanity checks. if frequency != 7: # pragma: no cover - raise RuntimeError("`frequency` should be `7`") + msg = "`frequency` should be `7`" + raise RuntimeError(msg) if len(actuals_ts) != 1: # pragma: no cover - raise RuntimeError( - "the hsma model can only predict one step into the future", - ) + msg = "the hsma model can only predict one step into the future" + raise RuntimeError(msg) # The "prediction" is calculated as the `np.mean()`. # As the `training_ts` covers only full week horizons, @@ -121,7 +124,7 @@ class HorizontalSMAModel(base.ForecastingModelABC): predictions = pd.DataFrame( data={ "actual": actuals_ts, - "prediction": training_ts.values.mean(), + "prediction": training_ts.to_numpy().mean(), "low80": float("NaN"), "high80": float("NaN"), "low95": float("NaN"), @@ -131,11 +134,11 @@ class HorizontalSMAModel(base.ForecastingModelABC): ) # Sanity checks. - if ( - predictions[["actual", "prediction"]].isnull().any().any() - ): # pragma: no cover - raise RuntimeError("missing predictions in hsma model") + if predictions[["actual", "prediction"]].isna().any().any(): # pragma: no cover + msg = "missing predictions in hsma model" + raise RuntimeError(msg) if predict_at not in predictions.index: # pragma: no cover - raise RuntimeError("missing prediction for `predict_at`") + msg = "missing prediction for `predict_at`" + raise RuntimeError(msg) return predictions diff --git a/src/velofy/forecasts/models/tactical/other.py b/src/velofy/forecasts/models/tactical/other.py index f515365..0d0008e 100644 --- a/src/velofy/forecasts/models/tactical/other.py +++ b/src/velofy/forecasts/models/tactical/other.py @@ -53,11 +53,11 @@ class TrivialModel(base.ForecastingModelABC): # Sanity checks. if frequency != 7: # pragma: no cover - raise RuntimeError("`frequency` should be `7`") + msg = "`frequency` should be `7`" + raise RuntimeError(msg) if len(actuals_ts) != 1: # pragma: no cover - raise RuntimeError( - "the trivial model can only predict one step into the future", - ) + msg = "the trivial model can only predict one step into the future" + raise RuntimeError(msg) # The "prediction" is simply `0.0`. predictions = pd.DataFrame( @@ -73,9 +73,11 @@ class TrivialModel(base.ForecastingModelABC): ) # Sanity checks. - if predictions["actual"].isnull().any(): # pragma: no cover - raise RuntimeError("missing actuals in trivial model") + if predictions["actual"].isna().any(): # pragma: no cover + msg = "missing actuals in trivial model" + raise RuntimeError(msg) if predict_at not in predictions.index: # pragma: no cover - raise RuntimeError("missing prediction for `predict_at`") + msg = "missing prediction for `predict_at`" + raise RuntimeError(msg) return predictions diff --git a/src/velofy/forecasts/models/tactical/realtime.py b/src/velofy/forecasts/models/tactical/realtime.py index e1399e6..9d0ce5b 100644 --- a/src/velofy/forecasts/models/tactical/realtime.py +++ b/src/velofy/forecasts/models/tactical/realtime.py @@ -57,7 +57,7 @@ class RealtimeARIMAModel(base.ForecastingModelABC): decomposed_training_ts = methods.decomposition.stl( time_series=training_ts, frequency=frequency, - # "Periodic" `ns` parameter => same seasonal component value + # "Periodic" `ns` parameter => Same seasonal component value # for observations of the same lag. ns=999, ) @@ -114,10 +114,13 @@ class RealtimeARIMAModel(base.ForecastingModelABC): # Sanity checks. if len(predictions) != 1: # pragma: no cover - raise RuntimeError("real-time models should predict exactly one time step") - if predictions.isnull().sum().any(): # pragma: no cover - raise RuntimeError("missing predictions in rtarima model") + msg = "real-time models should predict exactly one time step" + raise RuntimeError(msg) + if predictions.isna().sum().any(): # pragma: no cover + msg = "missing predictions in rtarima model" + raise RuntimeError(msg) if predict_at not in predictions.index: # pragma: no cover - raise RuntimeError("missing prediction for `predict_at`") + msg = "missing prediction for `predict_at`" + raise RuntimeError(msg) return predictions diff --git a/src/velofy/forecasts/models/tactical/vertical.py b/src/velofy/forecasts/models/tactical/vertical.py index d41da24..1a8f10d 100644 --- a/src/velofy/forecasts/models/tactical/vertical.py +++ b/src/velofy/forecasts/models/tactical/vertical.py @@ -57,7 +57,7 @@ class VerticalARIMAModel(base.ForecastingModelABC): decomposed_training_ts = methods.decomposition.stl( time_series=training_ts, frequency=frequency, - # "Periodic" `ns` parameter => same seasonal component value + # "Periodic" `ns` parameter => Same seasonal component value # for observations of the same lag. ns=999, ) @@ -114,10 +114,13 @@ class VerticalARIMAModel(base.ForecastingModelABC): # Sanity checks. if len(predictions) <= 1: # pragma: no cover - raise RuntimeError("vertical models should predict several time steps") - if predictions.isnull().sum().any(): # pragma: no cover - raise RuntimeError("missing predictions in varima model") + msg = "vertical models should predict several time steps" + raise RuntimeError(msg) + if predictions.isna().sum().any(): # pragma: no cover + msg = "missing predictions in varima model" + raise RuntimeError(msg) if predict_at not in predictions.index: # pragma: no cover - raise RuntimeError("missing prediction for `predict_at`") + msg = "missing prediction for `predict_at`" + raise RuntimeError(msg) return predictions diff --git a/src/velofy/forecasts/timify.py b/src/velofy/forecasts/timify.py index a51ae67..bc6414a 100644 --- a/src/velofy/forecasts/timify.py +++ b/src/velofy/forecasts/timify.py @@ -37,7 +37,8 @@ class OrderHistory: 60 * (pkg_config.SERVICE_END - pkg_config.SERVICE_START) / time_step ) if n_daily_time_steps != int(n_daily_time_steps): # pragma: no cover - raise RuntimeError("Internal error: configuration has invalid TIME_STEPS") + msg = "Internal error: configuration has invalid TIME_STEPS" + raise RuntimeError(msg) self._n_daily_time_steps = int(n_daily_time_steps) # The `_data` are populated by `.aggregate_orders()`. @@ -193,13 +194,15 @@ class OrderHistory: try: intra_pixel = self.totals.loc[pixel_id] except KeyError: - raise LookupError("The `pixel_id` is not in the `grid`") from None + msg = "The `pixel_id` is not in the `grid`" + raise LookupError(msg) from None first_order = intra_pixel[intra_pixel["n_orders"] > 0].index.min() # Sanity check: without an `Order`, the `Pixel` should not exist. if first_order is pd.NaT: # pragma: no cover - raise RuntimeError("no orders in the pixel") + msg = "no orders in the pixel" + raise RuntimeError(msg) # Return a proper `datetime.datetime` object. return dt.datetime( @@ -226,13 +229,15 @@ class OrderHistory: try: intra_pixel = self.totals.loc[pixel_id] except KeyError: - raise LookupError("The `pixel_id` is not in the `grid`") from None + msg = "The `pixel_id` is not in the `grid`" + raise LookupError(msg) from None last_order = intra_pixel[intra_pixel["n_orders"] > 0].index.max() # Sanity check: without an `Order`, the `Pixel` should not exist. if last_order is pd.NaT: # pragma: no cover - raise RuntimeError("no orders in the pixel") + msg = "no orders in the pixel" + raise RuntimeError(msg) # Return a proper `datetime.datetime` object. return dt.datetime( @@ -273,10 +278,12 @@ class OrderHistory: try: intra_pixel = self.totals.loc[pixel_id] except KeyError: - raise LookupError("The `pixel_id` is not in the `grid`") from None + msg = "The `pixel_id` is not in the `grid`" + raise LookupError(msg) from None if predict_at >= pkg_config.CUTOFF_DAY: # pragma: no cover - raise RuntimeError("Internal error: cannot predict beyond the given data") + msg = "Internal error: cannot predict beyond the given data" + raise RuntimeError(msg) # The first and last training day are just before the `predict_at` day # and span exactly `train_horizon` weeks covering only the times of the @@ -307,11 +314,13 @@ class OrderHistory: "n_orders", ] if len(training_ts) != frequency * train_horizon: - raise RuntimeError("Not enough historic data for `predict_at`") + msg = "Not enough historic data for `predict_at`" + raise RuntimeError(msg) actuals_ts = intra_pixel.loc[[predict_at], "n_orders"] if not len(actuals_ts): # pragma: no cover - raise LookupError("`predict_at` is not in the order history") + msg = "`predict_at` is not in the order history" + raise LookupError(msg) return training_ts, frequency, actuals_ts @@ -345,10 +354,12 @@ class OrderHistory: try: intra_pixel = self.totals.loc[pixel_id] except KeyError: - raise LookupError("The `pixel_id` is not in the `grid`") from None + msg = "The `pixel_id` is not in the `grid`" + raise LookupError(msg) from None if predict_day >= pkg_config.CUTOFF_DAY.date(): # pragma: no cover - raise RuntimeError("Internal error: cannot predict beyond the given data") + msg = "Internal error: cannot predict beyond the given data" + raise RuntimeError(msg) # The first and last training day are just before the `predict_day` # and span exactly `train_horizon` weeks covering all times of the day. @@ -378,7 +389,8 @@ class OrderHistory: "n_orders", ] if len(training_ts) != frequency * train_horizon: - raise RuntimeError("Not enough historic data for `predict_day`") + msg = "Not enough historic data for `predict_day`" + raise RuntimeError(msg) first_prediction_at = dt.datetime( predict_day.year, @@ -400,7 +412,8 @@ class OrderHistory: "n_orders", ] if not len(actuals_ts): # pragma: no cover - raise LookupError("`predict_day` is not in the order history") + msg = "`predict_day` is not in the order history" + raise LookupError(msg) return training_ts, frequency, actuals_ts @@ -434,10 +447,12 @@ class OrderHistory: try: intra_pixel = self.totals.loc[pixel_id] except KeyError: - raise LookupError("The `pixel_id` is not in the `grid`") from None + msg = "The `pixel_id` is not in the `grid`" + raise LookupError(msg) from None if predict_at >= pkg_config.CUTOFF_DAY: # pragma: no cover - raise RuntimeError("Internal error: cannot predict beyond the given data") + msg = "Internal error: cannot predict beyond the given data" + raise RuntimeError(msg) # The first and last training day are just before the `predict_at` day # and span exactly `train_horizon` weeks covering all times of the day, @@ -492,11 +507,13 @@ class OrderHistory: // self._time_step ) if len(training_ts) != frequency * train_horizon + n_time_steps_on_predict_day: - raise RuntimeError("Not enough historic data for `predict_day`") + msg = "Not enough historic data for `predict_day`" + raise RuntimeError(msg) actuals_ts = intra_pixel.loc[[predict_at], "n_orders"] if not len(actuals_ts): # pragma: no cover - raise LookupError("`predict_at` is not in the order history") + msg = "`predict_at` is not in the order history" + raise LookupError(msg) return training_ts, frequency, actuals_ts @@ -580,9 +597,7 @@ class OrderHistory: # For now, we only make forecasts with 7 and 8 weeks # as the training horizon (note:4f79e8fa). if train_horizon in {7, 8}: - if add >= 25: # = "high demand" - return models.HorizontalETSModel(order_history=self) - elif add >= 10: # = "medium demand" + if add >= 10: # = "high" or "medium demand" return models.HorizontalETSModel(order_history=self) elif add >= 2.5: # = "low demand" return models.HorizontalSMAModel(order_history=self) @@ -590,6 +605,5 @@ class OrderHistory: # = "no demand" return models.TrivialModel(order_history=self) - raise RuntimeError( - "no rule for the given average daily demand and training horizon", - ) + msg = "no rule for the given average daily demand and training horizon" + raise RuntimeError(msg) diff --git a/tests/conftest.py b/tests/conftest.py index bdb2e70..7264128 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -27,10 +27,12 @@ pytest_plugins = [ # The TESTING environment variable is set # in pyproject.toml in pytest's config section. if not os.getenv("TESTING"): - raise RuntimeError("Tests must be executed with TESTING set in the environment") + msg = "Tests must be executed with TESTING set in the environment" + raise RuntimeError(msg) if not pkg_config.TESTING: - raise RuntimeError("The testing configuration was not loaded") + msg = "The testing configuration was not loaded" + raise RuntimeError(msg) @pytest.fixture(scope="session", params=["all_at_once", "sequentially"]) diff --git a/tests/console/test_gridify.py b/tests/console/test_gridify.py index 660edb1..f730951 100644 --- a/tests/console/test_gridify.py +++ b/tests/console/test_gridify.py @@ -44,7 +44,7 @@ def test_two_pixels_with_two_addresses( side_length = max(city.total_x // 2, city.total_y // 2) + 1 # Hack the configuration regarding the grids to be created. - monkeypatch.setattr(velofy.config, "GRID_SIDE_LENGTHS", [side_length]) + monkeypatch.setattr(velofy.config, "GRID_SIDE_LENGTHS", (side_length,)) result = cli.invoke(gridify.gridify) diff --git a/tests/db/fake_data/fixture_makers.py b/tests/db/fake_data/fixture_makers.py index 571e506..0a93683 100644 --- a/tests/db/fake_data/fixture_makers.py +++ b/tests/db/fake_data/fixture_makers.py @@ -77,7 +77,7 @@ def make_order(make_address, make_courier, make_customer, make_restaurant): # Reset the identifiers before every test. factories.AdHocOrderFactory.reset_sequence(1) - def func(scheduled=False, restaurant=None, courier=None, **kwargs): + def func(*, scheduled=False, restaurant=None, courier=None, **kwargs): """Create a new `Order` object. Each `Order` is made by a new `Customer` with a unique `Address` for delivery. @@ -105,7 +105,7 @@ def make_order(make_address, make_courier, make_customer, make_restaurant): customer=make_customer(), # assume a unique `Customer` per order courier=courier, pickup_address=restaurant.address, # no `Address` history - delivery_address=make_address(), # unique `Customer` => new `Address` + delivery_address=make_address(), # unique `Customer` => New `Address` **kwargs, ) @@ -122,7 +122,7 @@ def make_replay_order(make_order, simulation): # Reset the identifiers before every test. factories.ReplayedOrderFactory.reset_sequence(1) - def func(scheduled=False, order=None, **kwargs): + def func(*, scheduled=False, order=None, **kwargs): """Create a new `ReplayedOrder` object. Each `ReplayOrder` is made by a new `Customer` with a unique `Address`. @@ -141,9 +141,12 @@ def make_replay_order(make_order, simulation): """ if scheduled: if order and order.ad_hoc is False: - raise RuntimeError("`order` must be scheduled") - elif order is None: + msg = "`order` must be scheduled" + raise RuntimeError(msg) + + if order is None: order = make_order(scheduled=True) + elif order is None: order = make_order() diff --git a/tests/db/test_grids.py b/tests/db/test_grids.py index a0f7e30..9561d43 100644 --- a/tests/db/test_grids.py +++ b/tests/db/test_grids.py @@ -83,9 +83,7 @@ class TestGridification: all considered `Order.pickup_address` attributes for some orders. """ mock = mocker.Mock() - query = ( - mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501 - ) + query = mock.query.return_value.join.return_value.filter.return_value.all monkeypatch.setattr(db, "session", mock) return query diff --git a/tests/db/test_orders.py b/tests/db/test_orders.py index 7ad31f7..3691cdd 100644 --- a/tests/db/test_orders.py +++ b/tests/db/test_orders.py @@ -1150,7 +1150,7 @@ class TestProperties: @pytest.mark.db @pytest.mark.no_cover -def test_make_random_orders( # noqa:C901 +def test_make_random_orders( db_session, make_address, make_courier, diff --git a/tests/db/test_pixels.py b/tests/db/test_pixels.py index bfba927..636328b 100644 --- a/tests/db/test_pixels.py +++ b/tests/db/test_pixels.py @@ -121,9 +121,7 @@ class TestProperties: def _restaurants_mock(self, mocker, monkeypatch, restaurant): """A `Mock` whose `.return_value` is `[restaurant]`.""" mock = mocker.Mock() - query = ( - mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501 - ) + query = mock.query.return_value.join.return_value.filter.return_value.all query.return_value = [restaurant] monkeypatch.setattr(db, "session", mock) diff --git a/tests/db/utils/test_locations.py b/tests/db/utils/test_locations.py index 193ed41..8257652 100644 --- a/tests/db/utils/test_locations.py +++ b/tests/db/utils/test_locations.py @@ -156,7 +156,7 @@ class TestProperties: result = location.zone_details zone, band = result - assert ZONE == f"{zone}{band}" + assert f"{zone}{band}" == ZONE class TestRelateTo: diff --git a/tests/forecasts/test_models.py b/tests/forecasts/test_models.py index f741ba1..ce8173a 100644 --- a/tests/forecasts/test_models.py +++ b/tests/forecasts/test_models.py @@ -1,5 +1,7 @@ """Tests for the `velofy.forecasts.models` sub-package.""" +import typing as t + import pandas as pd import pytest @@ -45,7 +47,7 @@ class TestGenericForecastingModelProperties: assert isinstance(result, str) - unique_model_names = set() + unique_model_names: t.ClassVar[set[str]] = set() def test_each_model_has_a_unique_name(self, model_cls, order_history): """The `*Model.name` values must be unique across all `*Model`s. @@ -131,8 +133,8 @@ class TestGenericForecastingModelProperties: train_horizon=test_config.LONG_TRAIN_HORIZON, ) - assert not result["actual"].isnull().any() - assert not result["prediction"].isnull().any() + assert not result["actual"].isna().any() + assert not result["prediction"].isna().any() @pytest.mark.db @pytest.mark.r diff --git a/tests/forecasts/timify/test_aggregate_orders.py b/tests/forecasts/timify/test_aggregate_orders.py index 534aee5..9b625bf 100644 --- a/tests/forecasts/timify/test_aggregate_orders.py +++ b/tests/forecasts/timify/test_aggregate_orders.py @@ -26,9 +26,7 @@ class TestAggregateOrders: Note: This fixture also exists in `tests.db.test_grids`. """ mock = mocker.Mock() - query = ( - mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501 - ) + query = mock.query.return_value.join.return_value.filter.return_value.all monkeypatch.setattr(db_session, "query", mock.query) return query diff --git a/tests/test_init_r.py b/tests/test_init_r.py index 7a6755a..ef493ab 100644 --- a/tests/test_init_r.py +++ b/tests/test_init_r.py @@ -14,6 +14,6 @@ def test_r_packages_installed(): in the "research/r_dependencies.ipynb" notebook or in the GitHub Actions CI. """ - from velofy import init_r + from velofy import init_r # noqa:PLC0415 assert init_r is not None diff --git a/uv.lock b/uv.lock index 636ec4c..b02ec76 100644 --- a/uv.lock +++ b/uv.lock @@ -884,6 +884,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/5d/57/a3adc5f380f50ef3d01014cb9d3b8c17b25de9b89def20d559def4fc3c4e/flake8-7.5.0-py2.py3-none-any.whl", hash = "sha256:637ea1a443a78ed6ee461725cdf71ca93bc5cde0abf25436dbebdc3880b4e078", size = 57487, upload-time = "2026-10-28T20:17:21.061Z" }, ] +[[package]] +name = "flake8-2020" +version = "1.8.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/cf/0b/e71a0d9efd854a631e2d51707676886997c73bec70c3c221b84601b976d2/flake8_2020-1.8.1.tar.gz", hash = "sha256:094ea95e8b614c3bd123fd4f007be28ec117ca57a6169903d4baaabe78e3e590", size = 4527, upload-time = "2023-06-10T19:05:11.43Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/36/f0/14c6c25768ddc81999733e7bed89e9285b273920505180155e351ed92dc5/flake8_2020-1.8.1-py2.py3-none-any.whl", hash = "sha256:59b6b8ac01cde10ef11b31a2c9aa15b4509d828ae115ee5be34464b9e4de4ea6", size = 4885, upload-time = "2023-06-10T19:05:09.965Z" }, +] + [[package]] name = "flake8-annotations" version = "3.3.1" @@ -922,6 +934,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/00/ba/8950a5ef5180c089f5ae474b60555acb0c079bc2b5dd55b7e8193e01be87/flake8_black-0.5.0-py3-none-any.whl", hash = "sha256:28c16f3c5421d1831ce27177926dbaa1d6d460da475afdcd230d409c35495ae7", size = 10167, upload-time = "2026-11-03T11:59:13.491Z" }, ] +[[package]] +name = "flake8-boolean-trap" +version = "1.0.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/df/4f/8ba91d20f54227fa791c4a8e52b9c9b8330f1093da1666de16d4fc8621c7/flake8_boolean_trap-1.0.1.tar.gz", hash = "sha256:603becf640de095fa8ef5e7f8d9945c525ea6913a75df27408be380fd7e0cb3f", size = 4524, upload-time = "2023-07-17T17:01:05.094Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/4a/98ecacb66251c8afc8bb9d364995688215f33b451d58be8817b03e4d23b5/flake8_boolean_trap-1.0.1-py3-none-any.whl", hash = "sha256:8c21b1ce2591028750c7a61760df525361b26ef02bf0e8032082dc7fd0d0f377", size = 4430, upload-time = "2023-07-17T17:01:03.636Z" }, +] + [[package]] name = "flake8-broken-line" version = "1.0.0" @@ -947,6 +971,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/46/ba/da7d4108baed185aecfc0c8cc8e64b2964f92a1897d3310b79c168ac94d3/flake8_bugbear-26.11.22-py3-none-any.whl", hash = "sha256:bc10d62be1dc512dc7825ee34c20492425370b209e47fb09a1dedd29eba49aca", size = 65763, upload-time = "2026-11-22T14:25:51.217Z" }, ] +[[package]] +name = "flake8-builtins" +version = "3.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7c/b9/2e42d77e5afe26439eba3df47c9764a4db2d88595531dea587afc3f9b823/flake8_builtins-3.2.0.tar.gz", hash = "sha256:f0c4cee9028711349b7bf18e9a04282a613fd426e56af00bcd0c3bb61ae25481", size = 18444, upload-time = "2026-11-01T10:24:32.991Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b6/02/c7614f54d3fde51b8a20d91e14b012a01c78c2a481d36b5e8e40535a3d0b/flake8_builtins-3.2.0-py3-none-any.whl", hash = "sha256:192a00630f183b8e7b881e98def18aa20124581dde3a3e7be7a01a6effe3504b", size = 18757, upload-time = "2026-11-01T10:24:31.47Z" }, +] + [[package]] name = "flake8-commas" version = "4.0.0" @@ -997,6 +1033,60 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/3f/7d/76a278fa43250441ed9300c344f889c7fb1817080c8fb8996b840bf421c2/flake8_docstrings-1.7.0-py2.py3-none-any.whl", hash = "sha256:51f2344026da083fc084166a9353f5082b01f72901df422f74b4d953ae88ac75", size = 4994, upload-time = "2023-01-25T14:27:12.32Z" }, ] +[[package]] +name = "flake8-errmsg" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/85/90/be4b2ebfe475a6429dc15fb183abcf9d177dd2320853fca6b5c1b5448812/flake8_errmsg-0.7.0.tar.gz", hash = "sha256:0af7480d4a892c94e7b399ecd38ea4b1889e2c7c8b398080c4c6e756cbacbe95", size = 14557, upload-time = "2026-06-18T14:56:02.366Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/62/47/2d71411967eabc97dc520fc80dc9ea275b07c0357c290e0e8ca1829bc448/flake8_errmsg-0.7.0-py3-none-any.whl", hash = "sha256:406c35d07fc7edc4deb2091e0d9a7177a2102d304f58d56ef18f782834a959f0", size = 9871, upload-time = "2026-06-18T14:56:01.245Z" }, +] + +[[package]] +name = "flake8-executable" +version = "2.1.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3b/41/f0687401d76d6031aa5fc447615e1a337308a9c5c586913f70c5a2abe832/flake8-executable-2.1.3.tar.gz", hash = "sha256:619fe023e00c3d8e5113521d7200e1ebb04587c12d157f9a2fb167feb8cae66b", size = 23035, upload-time = "2023-01-23T00:39:57.537Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bc/d7/311104f82226a6b108f7f05c56cfb7fe773847a879f622d6450ab0a227b3/flake8_executable-2.1.3-py3-none-any.whl", hash = "sha256:f0a66c97c3b99ce63bc1f01ce602d6bd048e4fc5dc0d7a13be2bfa3deb023a34", size = 35302, upload-time = "2023-01-23T00:39:55.485Z" }, +] + +[[package]] +name = "flake8-implicit-str-concat" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b0/83/cb6050d37bd7bcf01dc81ac20d3db96ffc41aca7f73f81fbf61223d5aa03/flake8_implicit_str_concat-0.7.0.tar.gz", hash = "sha256:492d6d1097ec51ca9e712bef9c5b2e8345867dfa8c744a12bf4ef014fdb18561", size = 9876, upload-time = "2026-07-24T12:15:18.04Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f8/3a/f4906c442afbfea281d7e03322c1761670dca950a4ef4abf1cab218fbc96/flake8_implicit_str_concat-0.7.0-py3-none-any.whl", hash = "sha256:fdabd6c6a314678364053b4a8682495692a43c22f229358e801f711999340d8b", size = 5998, upload-time = "2026-07-24T12:15:16.906Z" }, +] + +[[package]] +name = "flake8-logging" +version = "1.8.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/46/f0/572bd165c171c7a9ac1f82354c11edd09d0b86f35fa914b6db8cf64cce4f/flake8_logging-1.8.0.tar.gz", hash = "sha256:765046763d44d1dc051071c047fe0fa056d71a524505207c3fbdc47532e7d8af", size = 16754, upload-time = "2025-09-08T23:44:44.832Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7d/a3/0192ec49e7fe062130d545f4f6188142ca448b9b63a2622a4ba8ce7e728d/flake8_logging-1.8.0-py3-none-any.whl", hash = "sha256:bb3fcf0fb2b4f35d7ebb0c1dc02af16db00c7c858c5a018370172e939dd6f225", size = 11114, upload-time = "2025-09-08T23:44:43.32Z" }, +] + +[[package]] +name = "flake8-pie" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ae/11/cebfe54fda9897188ca40d1cd755d1be13908ceedfea9e500fae162f06a9/flake8-pie-0.16.0.tar.gz", hash = "sha256:b8dcb7b92706fa33d05d92a4b3e49b7a9fd3f0041849166275b646ba50e515ba", size = 28334, upload-time = "2022-08-08T23:51:12.62Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/83/4c/e953c2402b663155525faba5315df8abe6c02ea7f989cbf43327f5088fc3/flake8_pie-0.16.0-py3-none-any.whl", hash = "sha256:24cd7849b0eee22e2328b9e9d2a1dea40013b0a3106864bbadd06a4b05dbb71f", size = 49171, upload-time = "2022-08-08T23:51:14.535Z" }, +] + [[package]] name = "flake8-plugin-utils" version = "1.3.3" @@ -1039,6 +1129,30 @@ dependencies = [ ] sdist = { url = "https://files.pythonhosted.org/packages/dd/57/a173e3eb86072b7ee77650aca496b15d6886367d257f58ea9de5276e330a/flake8-quotes-3.4.0.tar.gz", hash = "sha256:aad8492fb710a2d3eabe68c5f86a1428de650c8484127e14c43d0504ba30276c", size = 14107, upload-time = "2024-02-10T21:58:22.357Z" } +[[package]] +name = "flake8-raise" +version = "0.0.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/45/3d/0211d7fb77b3bc6c49495575de4dd07b2ca6fc90a6784bca6097ec980cb9/flake8-raise-0.0.5.tar.gz", hash = "sha256:0a9890e16b851402d9b0d4fafe6c34890eab73835a2c2079c3850a25be575623", size = 5524, upload-time = "2020-01-26T13:53:15.354Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/da/b7/b8edb1ae5c517b8d3cd693129daab16282c5a4b4fc6ad4522cedc29eba61/flake8_raise-0.0.5-py3-none-any.whl", hash = "sha256:df26e5c542a58c8f8786d978e18ad7e54126a0ef5c6241c35dafaca7e2bbb808", size = 3694, upload-time = "2020-01-26T13:53:13.431Z" }, +] + +[[package]] +name = "flake8-return" +version = "1.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8-plugin-utils" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/83/49/43ee60c21b61fbec8e86858b2dac7d11a9bdd9958fd7f59077387b6a7197/flake8-return-1.2.0.tar.gz", hash = "sha256:68dfa56582cd704febd02ad86dcf5df67e38e0836d62f1ceae7930d76d3dd955", size = 10033, upload-time = "2022-10-28T09:37:12.507Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f0/8c/6aece77ad2d0d68d8f6e8d5471fd06638de11df656db7d76de810815c437/flake8_return-1.2.0-py3-none-any.whl", hash = "sha256:1f07af12954ed03ebe2c2aac2418f78b55374e9929d4956109664588f31582a1", size = 10121, upload-time = "2022-10-28T09:37:14.468Z" }, +] + [[package]] name = "flake8-sfs" version = "1.0.1" @@ -1051,6 +1165,30 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d1/a8/dc3b3dbe52808d3f09504950d20963a3e19ab1bf6492790b70b8b2e32565/flake8_sfs-1.0.1-py3-none-any.whl", hash = "sha256:ef5f6b3e6d958894fe4c953ecf8e6156d9ab620c7e138f68af5c0f9bfdb4f6b4", size = 6651, upload-time = "2025-09-21T09:31:41.166Z" }, ] +[[package]] +name = "flake8-simplify" +version = "0.31.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/57/3f/484e219a4ecc0242d36135ebe220470633dca035dcea9ce17ad72639db56/flake8_simplify-0.31.1.tar.gz", hash = "sha256:3830f39afed7dc76d6a6f4db006f5a460e1cb8ebe82e08c1d99c5f4e24fab26d", size = 19888, upload-time = "2026-10-06T14:52:31.849Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/11/58/0d4fd5b09de83c42e785b08c21b4bcd3e8f196284293a128037280475e40/flake8_simplify-0.31.1-py3-none-any.whl", hash = "sha256:642c1688a7308e00c6b2b2eb47b0cc66e6ee8440227b8540bab7d05e382279cc", size = 27446, upload-time = "2026-10-06T14:52:30.657Z" }, +] + +[[package]] +name = "flake8-tidy-imports" +version = "4.12.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/4d/24/ce374a8028f3f3d2c48082693d5b4a2b7073e6be64579ecff20bcefdb812/flake8_tidy_imports-4.12.0.tar.gz", hash = "sha256:9254788c3b6862c2fcec0250d2dc9af089afebff9c5b8a8ac8b9525b059b06db", size = 13946, upload-time = "2025-09-08T23:44:06.651Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/93/16/bc792adda2b19d501f474bbf6eb0b35546db01f4816459153bd69a388d03/flake8_tidy_imports-4.12.0-py3-none-any.whl", hash = "sha256:ab1e31a5ce07518a31c0a34cd92551f4c27639ae2c35a21364680a0318da312e", size = 10034, upload-time = "2025-09-08T23:44:05.535Z" }, +] + [[package]] name = "flake8-todos" version = "0.3.1" @@ -2364,6 +2502,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/08/ab/cce173d73200410f06306a89dbbb5f2125bd64f66ca5eff393d53d813288/pandas-3.1.1-cp315-cp315t-win_arm64.whl", hash = "sha256:4e6f9a3036fc6a40c5ba00efe4092a45844212bdb6a63eda4ad5a5a4c8da45eb", size = 10604158, upload-time = "2026-11-04T15:07:59.733Z" }, ] +[[package]] +name = "pandas-vet" +version = "2023.8.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "flake8" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f5/57/2c8350ff48cece1f6009012a0f42413e9e6d5ca54bec7f3b5726b6e33e1b/pandas_vet-2023.8.2.tar.gz", hash = "sha256:ee6b80b40f5a74de41c29393e4dce373447b363faaa3e0677e4f36799ea865c3", size = 9029, upload-time = "2023-08-11T15:09:03.945Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/17/dd/128ade78c67d4ac1a6202f320112aaa7934eaf8f7b0d861517e7c960dd3f/pandas_vet-2023.8.2-py3-none-any.whl", hash = "sha256:761c07b4479f24fc507465047111c7d21374ec678b7aba58e454fd5d3f8055fe", size = 7396, upload-time = "2023-08-11T15:09:04.842Z" }, +] + [[package]] name = "pandocfilters" version = "1.5.1" @@ -3687,6 +3838,19 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ad/66/0d785f0bc5e4315a96c989bb476d0fc07ea4f85132550c7b156ca2035d52/traitlets-5.16.1-py3-none-any.whl", hash = "sha256:f775618166caa0396c8e337099240f2bd3e5e917d203b2e6fbe21a58d3cb1f6b", size = 86211, upload-time = "2026-08-03T08:32:34.48Z" }, ] +[[package]] +name = "tryceratops" +version = "2.4.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "rich" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/2a/d3/43c2c190bb6b01decc92d87538b451d7fe8070aaaf18aa1e166bf432754e/tryceratops-2.4.1.tar.gz", hash = "sha256:fbfc14650004e27cd1e55ebb7c76b43ced04a4d3b4cbe42aac9d71e4623ed84d", size = 20595, upload-time = "2024-10-30T16:42:40.97Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/27/b5/88caeba349f17b7fd37b61bc88f81c138b3b5149b4e2a9deec66eaad1bdb/tryceratops-2.4.1-py3-none-any.whl", hash = "sha256:271b92367be89b243918a56361618607d2a9aa4aa4ba766ecfabd5f98c00480c", size = 27378, upload-time = "2024-10-30T16:42:38.914Z" }, +] + [[package]] name = "typing-extensions" version = "4.16.0" @@ -3778,29 +3942,43 @@ dev = [ { name = "autoflake" }, { name = "black" }, { name = "flake8" }, + { name = "flake8-2020" }, { name = "flake8-annotations" }, { name = "flake8-bandit" }, { name = "flake8-black" }, + { name = "flake8-boolean-trap" }, { name = "flake8-broken-line" }, { name = "flake8-bugbear" }, + { name = "flake8-builtins" }, { name = "flake8-commas" }, { name = "flake8-comprehensions" }, { name = "flake8-debugger" }, { name = "flake8-docstrings" }, + { name = "flake8-errmsg" }, + { name = "flake8-executable" }, + { name = "flake8-implicit-str-concat" }, + { name = "flake8-logging" }, + { name = "flake8-pie" }, { name = "flake8-pyproject" }, { name = "flake8-pytest-style" }, { name = "flake8-quotes" }, + { name = "flake8-raise" }, + { name = "flake8-return" }, { name = "flake8-sfs" }, + { name = "flake8-simplify" }, + { name = "flake8-tidy-imports" }, { name = "flake8-todos" }, { name = "flake8-unused-arguments" }, { name = "flynt" }, { name = "isort" }, { name = "mypy" }, { name = "nox" }, + { name = "pandas-vet" }, { name = "pep8-naming" }, { name = "pre-commit" }, { name = "pydoclint", extra = ["flake8"] }, { name = "ruff" }, + { name = "tryceratops" }, ] docs = [ { name = "sphinx" }, @@ -3844,29 +4022,43 @@ dev = [ { name = "autoflake", specifier = ">=2.4.0,<3.0.0" }, { name = "black", specifier = ">=25.12.0,<26.0.0" }, { name = "flake8", specifier = ">=7.5.0,<8.0.0" }, + { name = "flake8-2020", specifier = ">=1.8.1,<2.0.0" }, { name = "flake8-annotations", specifier = ">=3.3.1,<4.0.0" }, { name = "flake8-bandit", specifier = ">=4.1.1,<5.0.0" }, { name = "flake8-black", specifier = ">=0.5.0,<0.6.0" }, + { name = "flake8-boolean-trap", specifier = ">=1.0.1,<2.0.0" }, { name = "flake8-broken-line", specifier = ">=1.0.0,<2.0.0" }, { name = "flake8-bugbear", specifier = ">=26.11.22,<27.0.0" }, + { name = "flake8-builtins", specifier = ">=3.2.0,<4.0.0" }, { name = "flake8-commas", specifier = ">=4.0.0,<5.0.0" }, { name = "flake8-comprehensions", specifier = ">=3.17.0,<4.0.0" }, { name = "flake8-debugger", specifier = ">=4.1.2,<5.0.0" }, { name = "flake8-docstrings", specifier = ">=1.7.0,<2.0.0" }, + { name = "flake8-errmsg", specifier = ">=0.7.0,<0.8.0" }, + { name = "flake8-executable", specifier = ">=2.1.3,<3.0.0" }, + { name = "flake8-implicit-str-concat", specifier = ">=0.7.0,<0.8.0" }, + { name = "flake8-logging", specifier = ">=1.8.0,<2.0.0" }, + { name = "flake8-pie", specifier = ">=0.16.0,<0.17.0" }, { name = "flake8-pyproject", specifier = ">=1.2.4,<2.0.0" }, { name = "flake8-pytest-style", specifier = ">=2.2.0,<3.0.0" }, { name = "flake8-quotes", specifier = ">=3.4.0,<4.0.0" }, + { name = "flake8-raise", specifier = ">=0.0.5,<0.1.0" }, + { name = "flake8-return", specifier = ">=1.2.0,<2.0.0" }, { name = "flake8-sfs", specifier = ">=1.0.1,<2.0.0" }, + { name = "flake8-simplify", specifier = ">=0.31.1,<0.32.0" }, + { name = "flake8-tidy-imports", specifier = ">=4.12.0,<5.0.0" }, { name = "flake8-todos", specifier = ">=0.3.1,<0.4.0" }, { name = "flake8-unused-arguments", specifier = ">=0.0.14,<0.1.0" }, { name = "flynt", specifier = ">=1.0.6,<2.0.0" }, { name = "isort", specifier = ">=9.0.2,<10.0.0" }, { name = "mypy", specifier = ">=2.4.1,<3.0.0" }, { name = "nox", specifier = ">=2026.10.20" }, + { name = "pandas-vet", specifier = ">=2023.8.2" }, { name = "pep8-naming", specifier = ">=0.15.1,<0.16.0" }, { name = "pre-commit", specifier = ">=4.7.0,<5.0.0" }, { name = "pydoclint", extras = ["flake8"], specifier = ">=0.12.0,<0.13.0" }, { name = "ruff", specifier = ">=0.17.6,<0.18.0" }, + { name = "tryceratops", specifier = ">=2.4.1,<3.0.0" }, ] docs = [ { name = "sphinx", specifier = ">=9.2.0,<10.0.0" },