diff --git a/contracting_process/resource_level/coherent/milestone_status.py b/contracting_process/resource_level/coherent/milestone_status.py index 91ca15e..2db531f 100644 --- a/contracting_process/resource_level/coherent/milestone_status.py +++ b/contracting_process/resource_level/coherent/milestone_status.py @@ -1,6 +1,4 @@ -""" -If a milestone's ``status`` is unmet ('scheduled' or 'notMet'), then its ``dateMet`` is blank. -""" +"""If a milestone's ``status`` is unmet ('scheduled' or 'notMet'), then its ``dateMet`` is blank.""" from pelican.util.checks import complete_result_resource, get_empty_result_resource from pelican.util.getter import deep_get, get_values diff --git a/contracting_process/resource_level/coherent/procurement_method_vs_number_of_tenderers.py b/contracting_process/resource_level/coherent/procurement_method_vs_number_of_tenderers.py index 5a0e314..84df455 100644 --- a/contracting_process/resource_level/coherent/procurement_method_vs_number_of_tenderers.py +++ b/contracting_process/resource_level/coherent/procurement_method_vs_number_of_tenderers.py @@ -1,6 +1,4 @@ -""" -If the ``tender.procurementMethod`` is 'direct', then the ``tender.numberOfTenderers`` is at most 1. -""" +"""If the ``tender.procurementMethod`` is 'direct', then the ``tender.numberOfTenderers`` is at most 1.""" from pelican.util.checks import complete_result_resource_pass_fail, get_empty_result_resource from pelican.util.getter import deep_get diff --git a/contracting_process/resource_level/reference/contract_in_awards.py b/contracting_process/resource_level/reference/contract_in_awards.py index 3b24c05..82c181b 100644 --- a/contracting_process/resource_level/reference/contract_in_awards.py +++ b/contracting_process/resource_level/reference/contract_in_awards.py @@ -1,6 +1,4 @@ -""" -Each contract's ``awardID`` is present and matches the ``id`` of exactly one award. -""" +"""Each contract's ``awardID`` is present and matches the ``id`` of exactly one award.""" from collections import Counter diff --git a/contracting_process/resource_level/reference/parties.py b/contracting_process/resource_level/reference/parties.py index 636043b..8d22b36 100644 --- a/contracting_process/resource_level/reference/parties.py +++ b/contracting_process/resource_level/reference/parties.py @@ -1,6 +1,4 @@ -""" -Each referencing ``id`` is present and matches the ``id`` of exactly one party. -""" +"""Each referencing ``id`` is present and matches the ``id`` of exactly one party.""" from collections import Counter diff --git a/manage.py b/manage.py index 0e0d951..ee32051 100755 --- a/manage.py +++ b/manage.py @@ -12,9 +12,7 @@ def cli(): @cli.command() def update_exchange_rates(): - """ - Update the exchange rates. - """ + """Update the exchange rates.""" if settings.FIXER_IO_API_KEY: exchange_rates_db.update_from_fixer_io() @@ -25,9 +23,7 @@ def update_exchange_rates(): @click.option("--previous-dataset", type=int, help="ID of previous dataset for time-based checks.") @click.option("--sample", type=int, help="Number of compiled releases to import.") def add(name, collection_id, previous_dataset, sample): - """ - Create a dataset. - """ + """Create a dataset.""" message = {"name": name, "collection_id": collection_id, "ancestor_id": previous_dataset, "max_items": sample} publish(message, "ocds_kingfisher_extractor_init") @@ -37,9 +33,7 @@ def add(name, collection_id, previous_dataset, sample): @click.option("--include-filtered", is_flag=True, help="Remove its filtered datasets.") @click.option("--force", is_flag=True, help="Forcefully remove the dataset.") def remove(dataset_id, include_filtered, force): - """ - Delete a dataset. - """ + """Delete a dataset.""" cursor = get_cursor() cursor.execute("SELECT EXISTS (SELECT 1 FROM dataset WHERE id = %(id)s)", {"id": dataset_id}) @@ -179,17 +173,13 @@ def remove(dataset_id, include_filtered, force): @cli.group() def dev(): - """ - Commands for administrators and developers of Pelican backend. - """ + """Commands for administrators and developers of Pelican backend.""" @dev.command() @click.argument("dataset_id", type=int) def restart_dataset_check(dataset_id): - """ - Restart the dataset check if the check.dataset worker failed. - """ + """Restart the dataset check if the check.dataset worker failed.""" update_dataset_state(dataset_id, Phase.CONTRACTING_PROCESS, State.OK) commit() diff --git a/pelican/util/checks.py b/pelican/util/checks.py index b510195..8b70019 100644 --- a/pelican/util/checks.py +++ b/pelican/util/checks.py @@ -52,9 +52,7 @@ def get_empty_result_time_based(version: float = 1.0) -> dict[str, Any]: def get_empty_result_time_based_scope() -> dict[str, Any]: - """ - Initialize a time-based check result accumulator. - """ + """Initialize a time-based check result accumulator.""" return { "total_count": 0, "coverage_count": 0, diff --git a/pelican/util/currency_converter.py b/pelican/util/currency_converter.py index 05dc63a..ecfff5e 100644 --- a/pelican/util/currency_converter.py +++ b/pelican/util/currency_converter.py @@ -69,9 +69,7 @@ def import_data(data: list[tuple[datetime.date, dict[str, float]]]) -> None: def interpolation_closest(currency, start_date, end_date): - """ - start_date and end_date are exclusive. - """ + """start_date and end_date are exclusive.""" start_date_rate = rates[start_date][currency] end_date_rate = rates[end_date][currency] @@ -102,9 +100,7 @@ def interpolation_closest(currency, start_date, end_date): def interpolation_linear(currency, start_date, end_date): - """ - start_date and end_date are exclusive. - """ + """start_date and end_date are exclusive.""" start_date_rate = rates[start_date][currency] end_date_rate = rates[end_date][currency] diff --git a/pelican/util/services.py b/pelican/util/services.py index 5936cbc..1740a0a 100644 --- a/pelican/util/services.py +++ b/pelican/util/services.py @@ -49,17 +49,13 @@ def decode(body: bytes, content_type: str | None) -> Any: def consume(*args: Any, prefetch_count=1, **kwargs: Any) -> None: - """ - Consume messages from RabbitMQ. - """ + """Consume messages from RabbitMQ.""" client = AsyncConsumer(*args, prefetch_count=prefetch_count, **kwargs, **YAPW_KWARGS) client.start() def publish(*args: Any, **kwargs: Any) -> None: - """ - Publish a message to RabbitMQ. - """ + """Publish a message to RabbitMQ.""" client = Blocking(**YAPW_KWARGS) try: client.publish(*args, **kwargs) @@ -78,9 +74,7 @@ def dumps(self, obj): def get_cursor(name="") -> psycopg2.extensions.cursor: - """ - Connect to the database, if needed, and return a database cursor. - """ + """Connect to the database, if needed, and return a database cursor.""" global db_connected, db_connection, db_cursor_idx # noqa: PLW0603 if not db_connected: db_connection = psycopg2.connect(settings.DATABASE_URL) @@ -99,16 +93,12 @@ def get_cursor(name="") -> psycopg2.extensions.cursor: def commit() -> None: - """ - Commit the transaction. - """ + """Commit the transaction.""" db_connection.commit() def rollback() -> None: - """ - Rollback the transaction. - """ + """Rollback the transaction.""" db_connection.rollback() diff --git a/pyproject.toml b/pyproject.toml index a04e6af..dfbe547 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,28 +9,24 @@ target-version = "py311" [tool.ruff.lint] select = ["ALL"] ignore = [ - "ANN", "COM", "EM", - # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules - "W191", "D206", "Q000", "Q001", "Q002", "Q003", "ISC001", - "D203", "D212", # ignore incompatible rules - "D200", # documentation preferences - "C901", "PLR091", # complexity preferences - "D1", # docstrings - "PTH", # pathlib - "ARG001", # yapw callbacks - "DTZ001", "DTZ007", # allow naive datetimes from JSON data - "PLR2004", # magic values + "ANN", "C901", "COM812", "D203", "D212", "D415", "EM", "PERF203", "PLR091", "Q000", + "ARG001", # pika + "D1", + "DTZ", + "PLR2004", # magic + "PTH", + "D200", # https://github.com/astral-sh/ruff/issues/6269 ] [tool.ruff.lint.flake8-builtins] builtins-ignorelist = ["copyright"] +[tool.ruff.lint.flake8-unused-arguments] +ignore-variadic-names = true + [tool.ruff.lint.per-file-ignores] -"docs/conf.py" = ["INP001"] # no __init__.py file +"docs/conf.py" = ["D100", "INP001"] "tests/*" = [ - "D", # docstring - "PLR2004", # Magic value used - "PT009", # unittest asserts - "RUF012", # unittest attributes - "S101", # assert + "ARG001", "D", "FBT003", "INP001", "PLR2004", "S", "TRY003", + "RUF012", # examples ] diff --git a/time_variance/checks/ocid.py b/time_variance/checks/ocid.py index 2d1fb67..475d6b0 100644 --- a/time_variance/checks/ocid.py +++ b/time_variance/checks/ocid.py @@ -1,6 +1,4 @@ -""" -All OCIDs in an older collection of a data source are present in this newer collection of the same source. -""" +"""All OCIDs in an older collection of a data source are present in this newer collection of the same source.""" version = 1.0 diff --git a/workers/check/data_item.py b/workers/check/data_item.py index d16cc86..4e617e6 100644 --- a/workers/check/data_item.py +++ b/workers/check/data_item.py @@ -13,9 +13,7 @@ @click.command() def start(): - """ - Perform the field-level and compiled release-level checks. - """ + """Perform the field-level and compiled release-level checks.""" bootstrap() consume(on_message_callback=callback, queue=consume_routing_key, prefetch_count=multiprocessing.cpu_count()) diff --git a/workers/check/dataset.py b/workers/check/dataset.py index 8f80291..7753851 100644 --- a/workers/check/dataset.py +++ b/workers/check/dataset.py @@ -25,9 +25,7 @@ @click.command() def start(): - """ - Perform the dataset-level checks. - """ + """Perform the dataset-level checks.""" bootstrap() consume(on_message_callback=callback, queue=consume_routing_key) diff --git a/workers/check/time_based.py b/workers/check/time_based.py index cf89793..4dab677 100644 --- a/workers/check/time_based.py +++ b/workers/check/time_based.py @@ -11,9 +11,7 @@ @click.command() def start(): - """ - Perform the time-based checks. - """ + """Perform the time-based checks.""" consume(on_message_callback=callback, queue=consume_routing_key) diff --git a/workers/extract/dataset_filter.py b/workers/extract/dataset_filter.py index b766096..964bc1f 100644 --- a/workers/extract/dataset_filter.py +++ b/workers/extract/dataset_filter.py @@ -14,9 +14,7 @@ @click.command() def start(): - """ - Create filtered datasets. - """ + """Create filtered datasets.""" consume(on_message_callback=callback, queue=consume_routing_key) diff --git a/workers/extract/kingfisher_process.py b/workers/extract/kingfisher_process.py index 4e3bdcc..047dc1c 100644 --- a/workers/extract/kingfisher_process.py +++ b/workers/extract/kingfisher_process.py @@ -16,9 +16,7 @@ @click.command() def start(): - """ - Extract collections from Kingfisher Process. - """ + """Extract collections from Kingfisher Process.""" consume(on_message_callback=callback, queue=consume_routing_key) diff --git a/workers/report.py b/workers/report.py index d71bbc1..effb087 100644 --- a/workers/report.py +++ b/workers/report.py @@ -16,9 +16,7 @@ @click.command() def start(): - """ - Create reports, pick examples, and update dataset metadata. - """ + """Create reports, pick examples, and update dataset metadata.""" consume( on_message_callback=callback, queue=consume_routing_key, diff --git a/workers/wipe.py b/workers/wipe.py index 1b0e5b8..9f76da5 100644 --- a/workers/wipe.py +++ b/workers/wipe.py @@ -8,9 +8,7 @@ @click.command() def start(): - """ - Delete datasets. - """ + """Delete datasets.""" consume(on_message_callback=callback, queue=consume_routing_key)