diff --git a/noxfile.py b/noxfile.py index b47fdb7..3790b0c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -200,6 +200,7 @@ def lint_code(session: Session) -> None: # TODO: See comment on `mypy` below # 'mypy', "pep8-naming", + "pydoclint[flake8]", ) # Interpret extra arguments as `locations` of source files diff --git a/pyproject.toml b/pyproject.toml index e22fd0e..29dd17b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,6 +107,7 @@ dev = [ "flake8-unused-arguments (>=0.0.14,<0.1.0)", "mypy (>=2.4.1,<3.0.0)", "pep8-naming (>=0.15.1,<0.16.0)", + "pydoclint[flake8] (>=0.12.0,<0.13.0)", ] test = [ @@ -193,12 +194,8 @@ select = [ "E", "W", # pyflakes => basic errors "F4", "F5", "F6", "F7", "F8", "F9", - # ======================== - # wemake-python-styleguide - # Source: https://wemake-python-stylegui.de/en/latest/pages/usage/violations/index.html - # ======================== - # darglint => docstring matches implementation - "DAR0", "DAR1", "DAR2", "DAR3", "DAR4", "DAR5", + # pydoclint => docstring matches implementation + "DOC", # flake8-bandit => common security issues "S1", "S2", "S3", "S4", "S5", "S6", "S7", # flake8-broken-line => no \ to end a line @@ -243,6 +240,8 @@ ignore = [] extend-ignore = [ # 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", @@ -264,11 +263,11 @@ per-file-ignores = [ "migrations/versions/*.py:ANN0,ANN2,S608", # Type annotations are not strictly enforced. "noxfile.py:ANN0,ANN2", - # - ANN0, ANN2 => Type annotations are not strictly enforced. + # - ANN0, ANN2, DOC106, DOC107 => Type annotations are not strictly enforced. # - D106 => The `Meta` class inside the factory_boy models do not need a docstring. # - S101 => `assert` statements are ok in the test suite. # - S311 => The `random` module is not used for cryptography. - "tests/*.py:ANN0,ANN2,D106,S101,S311", + "tests/*.py:ANN0,ANN2,D106,DOC106,DOC107,S101,S311", ] # Explicitly set mccabe's maximum complexity to 10 as recommended by @@ -283,8 +282,11 @@ max-line-length = 88 # Preview the code lines that cause errors. show-source = true -# darglint -strictness = "long" +# pydoclint +style = "google" +arg-type-hints-in-docstring = false +check-return-types = false +check-yield-types = false # flake8-docstrings docstring-convention = "google" # flake8-quotes diff --git a/src/velofy/configuration.py b/src/velofy/configuration.py index bc93514..44cf262 100644 --- a/src/velofy/configuration.py +++ b/src/velofy/configuration.py @@ -107,7 +107,7 @@ def make_config(env: str = "production") -> Config: Raises: ValueError: if `env` is not as specified - """ # noqa:DAR203 + """ config: Config # otherwise mypy is confused if env.strip().lower() == "production": diff --git a/src/velofy/console/forecasts.py b/src/velofy/console/forecasts.py index b521623..6908693 100644 --- a/src/velofy/console/forecasts.py +++ b/src/velofy/console/forecasts.py @@ -24,7 +24,7 @@ from velofy.forecasts import timify @click.argument("time_step", default=60, type=int) @click.argument("train_horizon", default=8, type=int) @decorators.db_revision("8bfb928a31f8") -def tactical_heuristic( # noqa:C901 +def tactical_heuristic( # noqa:C901,DOC001 city: str, side_length: int, time_step: int, diff --git a/src/velofy/db/addresses.py b/src/velofy/db/addresses.py index c5ea84e..af13c98 100644 --- a/src/velofy/db/addresses.py +++ b/src/velofy/db/addresses.py @@ -136,7 +136,7 @@ class Address(meta.Base): Returns: self: enabling method chaining - """ # noqa:D402,DAR203 + """ # noqa:D402 self.city.clear_map() return self diff --git a/src/velofy/db/cities.py b/src/velofy/db/cities.py index 9435c60..b0fdaa5 100644 --- a/src/velofy/db/cities.py +++ b/src/velofy/db/cities.py @@ -101,7 +101,7 @@ class City(meta.Base): Returns: self: enabling method chaining - """ # noqa:DAR203 note:d334120e + """ # note:d334120e self._map = folium.Map( location=[self.center_latitude, self.center_longitude], zoom_start=self.initial_zoom, diff --git a/src/velofy/db/customers.py b/src/velofy/db/customers.py index e69e0f0..491389e 100644 --- a/src/velofy/db/customers.py +++ b/src/velofy/db/customers.py @@ -31,7 +31,7 @@ class Customer(meta.Base): Returns: self: enabling method chaining - """ # noqa:D402,DAR203 + """ # noqa:D402 self.orders[0].pickup_address.city.clear_map() return self diff --git a/src/velofy/db/grids.py b/src/velofy/db/grids.py index 69d7c98..f035174 100644 --- a/src/velofy/db/grids.py +++ b/src/velofy/db/grids.py @@ -116,7 +116,7 @@ class Grid(meta.Base): Returns: self: enabling method chaining - """ # noqa:D402,DAR203 + """ # noqa:D402 self.city.clear_map() return self diff --git a/src/velofy/db/pixels.py b/src/velofy/db/pixels.py index c079bb1..4eee7f1 100644 --- a/src/velofy/db/pixels.py +++ b/src/velofy/db/pixels.py @@ -132,7 +132,7 @@ class Pixel(meta.Base): Returns: self: enabling method chaining - """ # noqa:D402,DAR203 + """ # noqa:D402 self.grid.city.clear_map() return self diff --git a/src/velofy/db/restaurants.py b/src/velofy/db/restaurants.py index 1b70bc4..50a0cce 100644 --- a/src/velofy/db/restaurants.py +++ b/src/velofy/db/restaurants.py @@ -65,7 +65,7 @@ class Restaurant(meta.Base): Returns: self: enabling method chaining - """ # noqa:D402,DAR203 + """ # noqa:D402 self.address.city.clear_map() return self diff --git a/src/velofy/db/utils/locations.py b/src/velofy/db/utils/locations.py index 3bd57c7..21b4eef 100644 --- a/src/velofy/db/utils/locations.py +++ b/src/velofy/db/utils/locations.py @@ -46,6 +46,9 @@ class Location: Convention is {ZONE} {EASTING} {NORTHING}. + Returns: + text representation in the UTM system + Example: >>> Location(43.6532, -79.3832) diff --git a/src/velofy/forecasts/models/base.py b/src/velofy/forecasts/models/base.py index c1fc40a..2b60b85 100644 --- a/src/velofy/forecasts/models/base.py +++ b/src/velofy/forecasts/models/base.py @@ -52,7 +52,7 @@ class ForecastingModelABC(abc.ABC): actuals, predictions, and possibly 80%/95% confidence intervals; includes a row for the time step starting at `predict_at` and may contain further rows for other time steps on the same day - """ # noqa:DAR202 + """ def make_forecast( self, @@ -78,7 +78,8 @@ class ForecastingModelABC(abc.ABC): actual, prediction, and possibly 80%/95% confidence intervals for the time step starting at `predict_at` - # noqa:DAR401 RuntimeError + Raises: + RuntimeError: `*Model.predict()` misses the prediction for `predict_at` """ if ( cached_forecast := db.session.query(db.Forecast) diff --git a/src/velofy/forecasts/models/tactical/horizontal.py b/src/velofy/forecasts/models/tactical/horizontal.py index 51dab1f..6a08143 100644 --- a/src/velofy/forecasts/models/tactical/horizontal.py +++ b/src/velofy/forecasts/models/tactical/horizontal.py @@ -40,7 +40,8 @@ class HorizontalETSModel(base.ForecastingModelABC): confidence intervals (i.e, the four "low/high/80/95" columns); contains one row for the `predict_at` time step - # noqa:DAR401 RuntimeError + Raises: + RuntimeError: an internal consistency check fails """ # Generate the historic (and horizontal) order time series. training_ts, frequency, actuals_ts = self._order_history.make_horizontal_ts( @@ -96,7 +97,8 @@ class HorizontalSMAModel(base.ForecastingModelABC): this model does not support confidence intervals; contains one row for the `predict_at` time step - # noqa:DAR401 RuntimeError + Raises: + RuntimeError: an internal consistency check fails """ # Generate the historic (and horizontal) order time series. training_ts, frequency, actuals_ts = self._order_history.make_horizontal_ts( diff --git a/src/velofy/forecasts/models/tactical/other.py b/src/velofy/forecasts/models/tactical/other.py index 04c63d6..f515365 100644 --- a/src/velofy/forecasts/models/tactical/other.py +++ b/src/velofy/forecasts/models/tactical/other.py @@ -40,7 +40,8 @@ class TrivialModel(base.ForecastingModelABC): this model does not support confidence intervals; contains one row for the `predict_at` time step - # noqa:DAR401 RuntimeError + Raises: + RuntimeError: an internal consistency check fails """ # Generate the historic order time series mainly to check if a valid # `training_ts` exists (i.e., the demand history is long enough). diff --git a/src/velofy/forecasts/models/tactical/realtime.py b/src/velofy/forecasts/models/tactical/realtime.py index bf17a31..e1399e6 100644 --- a/src/velofy/forecasts/models/tactical/realtime.py +++ b/src/velofy/forecasts/models/tactical/realtime.py @@ -42,7 +42,8 @@ class RealtimeARIMAModel(base.ForecastingModelABC): confidence intervals (i.e, the four "low/high/80/95" columns); contains one row for the `predict_at` time step - # noqa:DAR401 RuntimeError + Raises: + RuntimeError: an internal consistency check fails """ # Generate the historic (and real-time) order time series. training_ts, frequency, actuals_ts = self._order_history.make_realtime_ts( diff --git a/src/velofy/forecasts/models/tactical/vertical.py b/src/velofy/forecasts/models/tactical/vertical.py index ebbc521..d41da24 100644 --- a/src/velofy/forecasts/models/tactical/vertical.py +++ b/src/velofy/forecasts/models/tactical/vertical.py @@ -42,7 +42,8 @@ class VerticalARIMAModel(base.ForecastingModelABC): confidence intervals (i.e, the four "low/high/80/95" columns); contains several rows, including one for the `predict_at` time step - # noqa:DAR401 RuntimeError + Raises: + RuntimeError: an internal consistency check fails """ # Generate the historic (and vertical) order time series. training_ts, frequency, actuals_ts = self._order_history.make_vertical_ts( diff --git a/src/velofy/forecasts/timify.py b/src/velofy/forecasts/timify.py index e5d928b..24b50e9 100644 --- a/src/velofy/forecasts/timify.py +++ b/src/velofy/forecasts/timify.py @@ -27,7 +27,8 @@ class OrderHistory: grid: pixel grid used to aggregate orders spatially time_step: interval length (in minutes) into which orders are aggregated - # noqa:DAR401 RuntimeError + Raises: + RuntimeError: the configuration has invalid `TIME_STEPS` """ self._grid = grid self._time_step = time_step @@ -183,8 +184,7 @@ class OrderHistory: Raises: LookupError: `pixel_id` not in `grid` - - # noqa:DAR401 RuntimeError + RuntimeError: no orders in the pixel """ try: intra_pixel = self.totals.loc[pixel_id] @@ -217,8 +217,7 @@ class OrderHistory: Raises: LookupError: `pixel_id` not in `grid` - - # noqa:DAR401 RuntimeError + RuntimeError: no orders in the pixel """ try: intra_pixel = self.totals.loc[pixel_id] @@ -565,7 +564,8 @@ class OrderHistory: Returns: most promising forecasting `*Model` - # noqa:DAR401 RuntimeError + Raises: + RuntimeError: no rule for the average daily demand and training horizon """ add = self.avg_daily_demand( pixel_id=pixel_id, diff --git a/tests/db/fake_data/fixture_makers.py b/tests/db/fake_data/fixture_makers.py index d2807b2..570e63c 100644 --- a/tests/db/fake_data/fixture_makers.py +++ b/tests/db/fake_data/fixture_makers.py @@ -78,7 +78,7 @@ def make_order(make_address, make_courier, make_customer, make_restaurant): scheduled: if an `Order` is a pre-order restaurant: who receives the `Order`; defaults to a new `Restaurant` courier: who delivered the `Order`; defaults to a new `Courier` - kwargs: additional keyword arguments forwarded to the `OrderFactory` + **kwargs: additional keyword arguments forwarded to the `OrderFactory` Returns: order @@ -119,7 +119,7 @@ def make_replay_order(make_order, simulation): Args: scheduled: if an `Order` is a pre-order order: the `Order` that is replayed - kwargs: keyword arguments forwarded to the `ReplayedOrderFactory` + **kwargs: keyword arguments forwarded to the `ReplayedOrderFactory` Returns: order diff --git a/uv.lock b/uv.lock index fbf3328..ee0e488 100644 --- a/uv.lock +++ b/uv.lock @@ -801,6 +801,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/c1/2b/238f02a4927fa2e27aa995371d240a468b52e42eae44a678434aff736b38/distlib-0.4.4-py2.py3-none-any.whl", hash = "sha256:cf09d55b1e85a89576b036aeb71550bfd68320f3f21761ca329eadadad918638", size = 472099, upload-time = "2026-10-16T13:56:32.053Z" }, ] +[[package]] +name = "docstring-parser-fork" +version = "0.0.16" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/04/ce/48b17c6c24d0af112f73721a90fac245450e548b82b53169260720f60d07/docstring_parser_fork-0.0.16.tar.gz", hash = "sha256:9ecf861ceab8b87d1297a71001c15a1956ad02e87434ee6473643a5988094f7c", size = 36360, upload-time = "2026-07-03T07:27:46.668Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c1/69/427c34e61827818942b48ececd7c892b8f58ba4ce4cfc89ba9fd8dbe8a8d/docstring_parser_fork-0.0.16-py3-none-any.whl", hash = "sha256:c024c97af582d6acf85a14f0b332b3a2ab08626648d251c25e47191f33064386", size = 25253, upload-time = "2026-07-03T07:27:45.591Z" }, +] + [[package]] name = "docutils" version = "0.23" @@ -2648,6 +2657,24 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b6/ae/315bbeee126a769cbde43cf4908acb4b40408d8bf8bbf334dd7368d8dadf/pycparser-3.12-py3-none-any.whl", hash = "sha256:a076f3f489b39b43ed13563a1dafe42447445bec2e294154ec5c57fcdda4c85e", size = 62600, upload-time = "2026-10-22T13:40:02.021Z" }, ] +[[package]] +name = "pydoclint" +version = "0.12.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "docstring-parser-fork" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9b/f7/ae03ad83f47dfee8a468544e4b77b254940299b15f9710e00450a5034729/pydoclint-0.12.0.tar.gz", hash = "sha256:ac061ae24381547e41d5a45044a1f88c87a54541b67ec959bd5160c69256482c", size = 255216, upload-time = "2026-10-28T06:48:34.428Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6e/45/9aea4898fcfbb3ed973eb23f6b83c677bb8bcecb59e9681fae6da82bb3be/pydoclint-0.12.0-py3-none-any.whl", hash = "sha256:28f5763a865cb19b54883dfe68b05b01d2c2fc2e8d59dcf424cc345bc976a689", size = 99545, upload-time = "2026-10-28T06:48:33.34Z" }, +] + +[package.optional-dependencies] +flake8 = [ + { name = "flake8" }, +] + [[package]] name = "pydocstyle" version = "6.3.0" @@ -3737,6 +3764,7 @@ dev = [ { name = "nox" }, { name = "pep8-naming" }, { name = "pre-commit" }, + { name = "pydoclint", extra = ["flake8"] }, ] docs = [ { name = "sphinx" }, @@ -3800,6 +3828,7 @@ dev = [ { name = "nox", specifier = ">=2026.10.20" }, { 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" }, ] docs = [ { name = "sphinx", specifier = ">=9.2.0,<10.0.0" },