From d7d430f2f99bfa3499d9af7272587dc31f844370 Mon Sep 17 00:00:00 2001 From: Jordan Cook Date: Mon, 11 Dec 2023 21:37:29 -0600 Subject: [PATCH] Use ruff for code formatting --- .pre-commit-config.yaml | 29 +- pyinaturalist/controllers/place_controller.py | 2 +- .../controllers/project_controller.py | 2 +- pyinaturalist/docs/model_docs.py | 4 +- pyinaturalist/v2/observations.py | 532 +++++++++--------- pyproject.toml | 146 +++-- .../test_observation_controller.py | 2 +- test/sample_data.py | 2 +- test/sample_data/get_observations_by_id.py | 8 +- .../get_taxa_autocomplete_minified.py | 20 +- test/test_converters.py | 2 +- test/test_formatters.py | 2 +- test/test_models.py | 1 + test/test_session.py | 2 +- 14 files changed, 385 insertions(+), 369 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e129a182..2dddeb19 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,31 +7,20 @@ repos: - id: end-of-file-fixer - id: mixed-line-ending - id: trailing-whitespace - - repo: https://github.com/psf/black - rev: 23.10.1 - hooks: - - id: black - - repo: https://github.com/asottile/blacken-docs - rev: 1.16.0 - hooks: - - id: blacken-docs - args: [--skip-errors, --skip-string-normalization] - - repo: https://github.com/timothycrosley/isort - rev: 5.12.0 - hooks: - - id: isort - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.1.4 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.7 hooks: - id: ruff - - repo: https://github.com/yunojuno/pre-commit-xenon - rev: v0.1 - hooks: - - id: xenon - args: [--max-average=A, --max-modules=C, --max-absolute=C] + args: [ --fix ] + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.6.1 hooks: - id: mypy additional_dependencies: [attrs, types-python-dateutil, types-requests, types-ujson] exclude: ^examples/ + - repo: https://github.com/yunojuno/pre-commit-xenon + rev: v0.1 + hooks: + - id: xenon + args: [--max-average=A, --max-modules=C, --max-absolute=C] diff --git a/pyinaturalist/controllers/place_controller.py b/pyinaturalist/controllers/place_controller.py index f9f2388d..8534e7fa 100644 --- a/pyinaturalist/controllers/place_controller.py +++ b/pyinaturalist/controllers/place_controller.py @@ -68,7 +68,7 @@ def nearby( swlat: float, swlng: float, name: Optional[str] = None, - **params + **params, ) -> Paginator[Place]: """Search for places near a given location diff --git a/pyinaturalist/controllers/project_controller.py b/pyinaturalist/controllers/project_controller.py index 8009e923..ed2caf76 100644 --- a/pyinaturalist/controllers/project_controller.py +++ b/pyinaturalist/controllers/project_controller.py @@ -88,7 +88,7 @@ def add_observations( project_id=project_id, observation_id=observation_id, auth=True, - **params + **params, ) responses.append(response) return responses diff --git a/pyinaturalist/docs/model_docs.py b/pyinaturalist/docs/model_docs.py index 942d7c71..7b0fc875 100644 --- a/pyinaturalist/docs/model_docs.py +++ b/pyinaturalist/docs/model_docs.py @@ -44,7 +44,7 @@ def get_model_doc(cls: Type, config: Config) -> List[Tuple[str, str, str]]: options in the description. """ # Used internally by sphinx-autodoc-typehints - config._annotation_globals = getattr(cls, "__globals__", {}) + config._annotation_globals = getattr(cls, '__globals__', {}) doc_rows = [ _get_field_doc(field, config) @@ -58,7 +58,7 @@ def get_model_doc(cls: Type, config: Config) -> List[Tuple[str, str, str]]: _get_lazy_property_doc(prop, config) for _, prop in get_lazy_properties(cls).items() ] - delattr(config, "_annotation_globals") + delattr(config, '_annotation_globals') return doc_rows diff --git a/pyinaturalist/v2/observations.py b/pyinaturalist/v2/observations.py index 36ab6600..8bf435f5 100644 --- a/pyinaturalist/v2/observations.py +++ b/pyinaturalist/v2/observations.py @@ -140,305 +140,305 @@ def _get_post_observations(params: RequestParams) -> JsonResponse: # The full `fields` value to request all observation details ALL_OBS_FIELDS = { - "annotations": { - "controlled_attribute": {"id": True, "label": True, "multivalued": True}, - "controlled_value": {"id": True, "label": True, "multivalued": True}, - "user": {"login": True, "icon_url": True}, - "vote_score": True, - "votes": {"vote_flag": True, "user": {"login": True, "icon_url": True}}, + 'annotations': { + 'controlled_attribute': {'id': True, 'label': True, 'multivalued': True}, + 'controlled_value': {'id': True, 'label': True, 'multivalued': True}, + 'user': {'login': True, 'icon_url': True}, + 'vote_score': True, + 'votes': {'vote_flag': True, 'user': {'login': True, 'icon_url': True}}, }, - "application": {"icon": True, "name": True, "url": True}, - "comments": { - "body": True, - "created_at": True, - "flags": {"id": True}, - "hidden": True, - "id": True, - "moderator_actions": { - "action": True, - "id": True, - "created_at": True, - "reason": True, - "user": {"login": True, "icon_url": True}, + 'application': {'icon': True, 'name': True, 'url': True}, + 'comments': { + 'body': True, + 'created_at': True, + 'flags': {'id': True}, + 'hidden': True, + 'id': True, + 'moderator_actions': { + 'action': True, + 'id': True, + 'created_at': True, + 'reason': True, + 'user': {'login': True, 'icon_url': True}, }, - "spam": True, - "user": {"login": True, "icon_url": True}, + 'spam': True, + 'user': {'login': True, 'icon_url': True}, }, - "community_taxon": { - "ancestry": True, - "ancestor_ids": True, - "ancestors": { - "id": True, - "uuid": True, - "name": True, - "iconic_taxon_name": True, - "is_active": True, - "preferred_common_name": True, - "rank": True, - "rank_level": True, + 'community_taxon': { + 'ancestry': True, + 'ancestor_ids': True, + 'ancestors': { + 'id': True, + 'uuid': True, + 'name': True, + 'iconic_taxon_name': True, + 'is_active': True, + 'preferred_common_name': True, + 'rank': True, + 'rank_level': True, }, - "default_photo": { - "attribution": True, - "license_code": True, - "url": True, - "square_url": True, + 'default_photo': { + 'attribution': True, + 'license_code': True, + 'url': True, + 'square_url': True, }, - "iconic_taxon_name": True, - "id": True, - "is_active": True, - "name": True, - "preferred_common_name": True, - "rank": True, - "rank_level": True, + 'iconic_taxon_name': True, + 'id': True, + 'is_active': True, + 'name': True, + 'preferred_common_name': True, + 'rank': True, + 'rank_level': True, }, - "created_at": True, - "description": True, - "faves": {"id": True, "user": {"login": True, "icon_url": True}}, - "flags": {"id": True, "flag": True, "resolved": True}, - "geojson": True, - "geoprivacy": True, - "id": True, - "identifications": { - "body": True, - "category": True, - "created_at": True, - "current": True, - "disagreement": True, - "flags": {"id": True}, - "hidden": True, - "moderator_actions": { - "action": True, - "id": True, - "created_at": True, - "reason": True, - "user": {"login": True, "icon_url": True}, + 'created_at': True, + 'description': True, + 'faves': {'id': True, 'user': {'login': True, 'icon_url': True}}, + 'flags': {'id': True, 'flag': True, 'resolved': True}, + 'geojson': True, + 'geoprivacy': True, + 'id': True, + 'identifications': { + 'body': True, + 'category': True, + 'created_at': True, + 'current': True, + 'disagreement': True, + 'flags': {'id': True}, + 'hidden': True, + 'moderator_actions': { + 'action': True, + 'id': True, + 'created_at': True, + 'reason': True, + 'user': {'login': True, 'icon_url': True}, }, - "previous_observation_taxon": { - "ancestry": True, - "ancestor_ids": True, - "ancestors": { - "id": True, - "uuid": True, - "name": True, - "iconic_taxon_name": True, - "is_active": True, - "preferred_common_name": True, - "rank": True, - "rank_level": True, + 'previous_observation_taxon': { + 'ancestry': True, + 'ancestor_ids': True, + 'ancestors': { + 'id': True, + 'uuid': True, + 'name': True, + 'iconic_taxon_name': True, + 'is_active': True, + 'preferred_common_name': True, + 'rank': True, + 'rank_level': True, }, - "default_photo": { - "attribution": True, - "license_code": True, - "url": True, - "square_url": True, + 'default_photo': { + 'attribution': True, + 'license_code': True, + 'url': True, + 'square_url': True, }, - "iconic_taxon_name": True, - "id": True, - "is_active": True, - "name": True, - "preferred_common_name": True, - "rank": True, - "rank_level": True, + 'iconic_taxon_name': True, + 'id': True, + 'is_active': True, + 'name': True, + 'preferred_common_name': True, + 'rank': True, + 'rank_level': True, }, - "spam": True, - "taxon": { - "ancestry": True, - "ancestor_ids": True, - "ancestors": { - "id": True, - "uuid": True, - "name": True, - "iconic_taxon_name": True, - "is_active": True, - "preferred_common_name": True, - "rank": True, - "rank_level": True, + 'spam': True, + 'taxon': { + 'ancestry': True, + 'ancestor_ids': True, + 'ancestors': { + 'id': True, + 'uuid': True, + 'name': True, + 'iconic_taxon_name': True, + 'is_active': True, + 'preferred_common_name': True, + 'rank': True, + 'rank_level': True, }, - "default_photo": { - "attribution": True, - "license_code": True, - "url": True, - "square_url": True, + 'default_photo': { + 'attribution': True, + 'license_code': True, + 'url': True, + 'square_url': True, }, - "iconic_taxon_name": True, - "id": True, - "is_active": True, - "name": True, - "preferred_common_name": True, - "rank": True, - "rank_level": True, + 'iconic_taxon_name': True, + 'id': True, + 'is_active': True, + 'name': True, + 'preferred_common_name': True, + 'rank': True, + 'rank_level': True, }, - "taxon_change": {"id": True, "type": True}, - "updated_at": True, - "user": {"login": True, "icon_url": True, "id": True}, - "uuid": True, - "vision": True, + 'taxon_change': {'id': True, 'type': True}, + 'updated_at': True, + 'user': {'login': True, 'icon_url': True, 'id': True}, + 'uuid': True, + 'vision': True, }, - "identifications_most_agree": True, - "latitude": True, - "license_code": True, - "location": True, - "longitude": True, - "map_scale": True, - "non_traditional_projects": { - "current_user_is_member": True, - "project_user": {"user": {"login": True, "icon_url": True}}, - "project": { - "admins": {"user_id": True}, - "icon": True, - "project_observation_fields": { - "id": True, - "observation_field": { - "allowed_values": True, - "datatype": True, - "description": True, - "id": True, - "name": True, + 'identifications_most_agree': True, + 'latitude': True, + 'license_code': True, + 'location': True, + 'longitude': True, + 'map_scale': True, + 'non_traditional_projects': { + 'current_user_is_member': True, + 'project_user': {'user': {'login': True, 'icon_url': True}}, + 'project': { + 'admins': {'user_id': True}, + 'icon': True, + 'project_observation_fields': { + 'id': True, + 'observation_field': { + 'allowed_values': True, + 'datatype': True, + 'description': True, + 'id': True, + 'name': True, }, }, - "slug": True, - "title": True, + 'slug': True, + 'title': True, }, }, - "obscured": True, - "observed_on": True, - "observed_time_zone": True, - "ofvs": { - "observation_field": { - "allowed_values": True, - "datatype": True, - "description": True, - "name": True, - "taxon": {"name": True}, - "uuid": True, + 'obscured': True, + 'observed_on': True, + 'observed_time_zone': True, + 'ofvs': { + 'observation_field': { + 'allowed_values': True, + 'datatype': True, + 'description': True, + 'name': True, + 'taxon': {'name': True}, + 'uuid': True, }, - "user": {"login": True, "icon_url": True}, - "uuid": True, - "value": True, - "taxon": { - "ancestry": True, - "ancestor_ids": True, - "ancestors": { - "id": True, - "uuid": True, - "name": True, - "iconic_taxon_name": True, - "is_active": True, - "preferred_common_name": True, - "rank": True, - "rank_level": True, + 'user': {'login': True, 'icon_url': True}, + 'uuid': True, + 'value': True, + 'taxon': { + 'ancestry': True, + 'ancestor_ids': True, + 'ancestors': { + 'id': True, + 'uuid': True, + 'name': True, + 'iconic_taxon_name': True, + 'is_active': True, + 'preferred_common_name': True, + 'rank': True, + 'rank_level': True, }, - "default_photo": { - "attribution": True, - "license_code": True, - "url": True, - "square_url": True, + 'default_photo': { + 'attribution': True, + 'license_code': True, + 'url': True, + 'square_url': True, }, - "iconic_taxon_name": True, - "id": True, - "is_active": True, - "name": True, - "preferred_common_name": True, - "rank": True, - "rank_level": True, + 'iconic_taxon_name': True, + 'id': True, + 'is_active': True, + 'name': True, + 'preferred_common_name': True, + 'rank': True, + 'rank_level': True, }, }, - "outlinks": {"source": True, "url": True}, - "photos": { - "id": True, - "uuid": True, - "url": True, - "license_code": True, - "flags": {"id": True, "flag": True, "resolved": True}, + 'outlinks': {'source': True, 'url': True}, + 'photos': { + 'id': True, + 'uuid': True, + 'url': True, + 'license_code': True, + 'flags': {'id': True, 'flag': True, 'resolved': True}, }, - "place_guess": True, - "place_ids": True, - "positional_accuracy": True, - "preferences": {"prefers_community_taxon": True}, - "private_geojson": True, - "private_place_guess": True, - "private_place_ids": True, - "project_observations": { - "current_user_is_member": True, - "preferences": {"allows_curator_coordinate_access": True}, - "project": { - "admins": {"user_id": True}, - "icon": True, - "project_observation_fields": { - "id": True, - "observation_field": { - "allowed_values": True, - "datatype": True, - "description": True, - "id": True, - "name": True, + 'place_guess': True, + 'place_ids': True, + 'positional_accuracy': True, + 'preferences': {'prefers_community_taxon': True}, + 'private_geojson': True, + 'private_place_guess': True, + 'private_place_ids': True, + 'project_observations': { + 'current_user_is_member': True, + 'preferences': {'allows_curator_coordinate_access': True}, + 'project': { + 'admins': {'user_id': True}, + 'icon': True, + 'project_observation_fields': { + 'id': True, + 'observation_field': { + 'allowed_values': True, + 'datatype': True, + 'description': True, + 'id': True, + 'name': True, }, }, - "slug": True, - "title": True, + 'slug': True, + 'title': True, }, - "uuid": True, + 'uuid': True, }, - "public_positional_accuracy": True, - "quality_grade": True, - "reviewed_by": True, - "sounds": { - "file_url": True, - "file_content_type": True, - "id": True, - "license_code": True, - "play_local": True, - "url": True, - "uuid": True, + 'public_positional_accuracy': True, + 'quality_grade': True, + 'reviewed_by': True, + 'sounds': { + 'file_url': True, + 'file_content_type': True, + 'id': True, + 'license_code': True, + 'play_local': True, + 'url': True, + 'uuid': True, }, - "tags": True, - "taxon": { - "ancestry": True, - "ancestor_ids": True, - "ancestors": { - "id": True, - "uuid": True, - "name": True, - "iconic_taxon_name": True, - "is_active": True, - "preferred_common_name": True, - "rank": True, - "rank_level": True, + 'tags': True, + 'taxon': { + 'ancestry': True, + 'ancestor_ids': True, + 'ancestors': { + 'id': True, + 'uuid': True, + 'name': True, + 'iconic_taxon_name': True, + 'is_active': True, + 'preferred_common_name': True, + 'rank': True, + 'rank_level': True, }, - "default_photo": { - "attribution": True, - "license_code": True, - "url": True, - "square_url": True, + 'default_photo': { + 'attribution': True, + 'license_code': True, + 'url': True, + 'square_url': True, }, - "iconic_taxon_name": True, - "id": True, - "is_active": True, - "name": True, - "preferred_common_name": True, - "rank": True, - "rank_level": True, + 'iconic_taxon_name': True, + 'id': True, + 'is_active': True, + 'name': True, + 'preferred_common_name': True, + 'rank': True, + 'rank_level': True, }, - "taxon_geoprivacy": True, - "time_observed_at": True, - "time_zone": True, - "user": { - "login": True, - "icon_url": True, - "id": True, - "name": True, - "observations_count": True, - "preferences": { - "prefers_community_taxa": True, - "prefers_observation_fields_by": True, - "prefers_project_addition_by": True, + 'taxon_geoprivacy': True, + 'time_observed_at': True, + 'time_zone': True, + 'user': { + 'login': True, + 'icon_url': True, + 'id': True, + 'name': True, + 'observations_count': True, + 'preferences': { + 'prefers_community_taxa': True, + 'prefers_observation_fields_by': True, + 'prefers_project_addition_by': True, }, }, - "viewer_trusted_by_observer": True, - "votes": { - "id": True, - "user": {"login": True, "icon_url": True, "id": True}, - "vote_flag": True, - "vote_scope": True, + 'viewer_trusted_by_observer': True, + 'votes': { + 'id': True, + 'user': {'login': True, 'icon_url': True, 'id': True}, + 'vote_flag': True, + 'vote_scope': True, }, } diff --git a/pyproject.toml b/pyproject.toml index 4ab21233..6912d09f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,8 +8,17 @@ readme = "README.md" homepage = "https://github.com/pyinat/pyinaturalist" repository = "https://github.com/pyinat/pyinaturalist" documentation = "https://pyinaturalist.readthedocs.io" -keywords = ["inaturalist", "biodiversity", "conservation", "citizen-science", "community-science", - "api", "api-client", "data-model", "requests"] +keywords = [ + "inaturalist", + "biodiversity", + "conservation", + "citizen-science", + "community-science", + "api", + "api-client", + "data-model", + "requests", +] classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", @@ -23,68 +32,78 @@ include = [ { path = "*.yml" }, { path = "docs", format = "sdist" }, { path = "examples", format = "sdist" }, - { path = "test", format = "sdist" } -] -packages = [ - { include = "pyinaturalist" }, - { include = "pyinat" }, + { path = "test", format = "sdist" }, ] +packages = [{ include = "pyinaturalist" }, { include = "pyinat" }] [tool.poetry.dependencies] -python = "^3.7" -attrs = ">=21.2" -keyring = ">=22.3" -platformdirs = ">=2.6" -python-dateutil = ">=2.0" -python-forge = ">=18.6" -requests = ">=2.25" -requests-cache = ">=1.1" -requests-ratelimiter = ">=0.3.2" -rich = ">=10.9" +python = "^3.7" +attrs = ">=21.2" +keyring = ">=22.3" +platformdirs = ">=2.6" +python-dateutil = ">=2.0" +python-forge = ">=18.6" +requests = ">=2.25" +requests-cache = ">=1.1" +requests-ratelimiter = ">=0.3.2" +rich = ">=10.9" # Workaround for package conflicts on python 3.7; required for rich -markdown-it-py = [ - {python="3.7", version="2.2"}, - {python=">=3.8", version=">=3.0"}, - ] +markdown-it-py = [ + { python = "3.7", version = "2.2" }, + { python = ">=3.8", version = ">=3.0" }, +] # Optional dependencies -ujson = {optional=true, version=">5.0"} +ujson = { optional = true, version = ">5.0" } # Documentation dependencies needed for Readthedocs builds -furo = {optional=true, python=">=3.8", version="^2023.7"} -ipython = {optional=true, python=">=3.8", version="^8.12"} -linkify-it-py = {optional=true, python=">=3.8", version="^2.0"} -matplotlib = {optional=true, python=">=3.8", version=">=3.7"} -myst-parser = {optional=true, python=">=3.8", version=">=1.0"} -nbsphinx = {optional=true, python=">=3.8", version="^0.9"} -pillow = {optional=true, python=">=3.8", version=">=10.1"} -sphinx = {optional=true, python=">=3.8", version="^6.2"} -sphinx-automodapi = {optional=true, python=">=3.8", version="^0.15"} -sphinx-autodoc-typehints = {optional=true, python=">=3.8", version="1.20"} -sphinx-copybutton = {optional=true, python=">=3.8", version=">=0.5"} -sphinx-design = {optional=true, python=">=3.8", version=">=0.5"} -sphinxcontrib-apidoc = {optional=true, python=">=3.8", version="^0.3"} -sphinxext-opengraph = {optional=true, python=">=3.8", version=">=0.9"} +furo = { optional = true, python = ">=3.8", version = "^2023.7" } +ipython = { optional = true, python = ">=3.8", version = "^8.12" } +linkify-it-py = { optional = true, python = ">=3.8", version = "^2.0" } +matplotlib = { optional = true, python = ">=3.8", version = ">=3.7" } +myst-parser = { optional = true, python = ">=3.8", version = ">=1.0" } +nbsphinx = { optional = true, python = ">=3.8", version = "^0.9" } +pillow = { optional = true, python = ">=3.8", version = ">=10.1" } +sphinx = { optional = true, python = ">=3.8", version = "^6.2" } +sphinx-automodapi = { optional = true, python = ">=3.8", version = "^0.15" } +sphinx-autodoc-typehints = { optional = true, python = ">=3.8", version = "1.20" } +sphinx-copybutton = { optional = true, python = ">=3.8", version = ">=0.5" } +sphinx-design = { optional = true, python = ">=3.8", version = ">=0.5" } +sphinxcontrib-apidoc = { optional = true, python = ">=3.8", version = "^0.3" } +sphinxext-opengraph = { optional = true, python = ">=3.8", version = ">=0.9" } [tool.poetry.dev-dependencies] -coverage = ">=7.2" -nox = "^2023.4" -nox-poetry = "^1.0.0" -pre-commit = "^2.19" -pretty-errors = ">=1.2" -pytest = "^7.0" -pytest-asyncio = ">=0.21" -pytest-cov = ">=3.0" -pytest-xdist = ">=2.2" -requests-mock = "^1.8" -sphinx-autobuild = {python=">=3.8", version=">=2021.3"} +coverage = ">=7.2" +nox = "^2023.4" +nox-poetry = "^1.0.0" +pre-commit = "^2.19" +pretty-errors = ">=1.2" +pytest = "^7.0" +pytest-asyncio = ">=0.21" +pytest-cov = ">=3.0" +pytest-xdist = ">=2.2" +requests-mock = "^1.8" +sphinx-autobuild = { python = ">=3.8", version = ">=2021.3" } [tool.poetry.extras] all = ["ujson"] -docs = ["furo", "ipython", "linkify-it-py", "matplotlib", "myst-parser", "nbsphinx", "pillow", - "sphinx", "sphinx-automodapi", "sphinx-autodoc-typehints", "sphinx-copybutton", - "sphinx-design", "sphinxcontrib-apidoc", "sphinxext-opengraph"] +docs = [ + "furo", + "ipython", + "linkify-it-py", + "matplotlib", + "myst-parser", + "nbsphinx", + "pillow", + "sphinx", + "sphinx-automodapi", + "sphinx-autodoc-typehints", + "sphinx-copybutton", + "sphinx-design", + "sphinxcontrib-apidoc", + "sphinxext-opengraph", +] [build-system] requires = ["poetry-core>=1.0.0"] @@ -103,10 +122,7 @@ source = ['pyinaturalist', 'pyinat'] omit = ['pyinaturalist/docs/model_docs.py'] [tool.coverage.report] -exclude_lines = [ - 'pragma: no cover', - 'if TYPE_CHECKING:', -] +exclude_lines = ['pragma: no cover', 'if TYPE_CHECKING:'] [tool.isort] profile = 'black' @@ -124,10 +140,20 @@ markers = [ ] [tool.ruff] -line-length = 120 +fix = true +unsafe-fixes = true +line-length = 100 output-format = 'grouped' -select = ['B', 'C4','C90', 'E', 'F'] -ignore = ['B023', 'F403'] -exclude = [ - 'test/sample_data/' -] +select = ['B', 'C4', 'C90', 'E', 'F'] +target-version = 'py37' +exclude = ['examples/', 'test/sample_data/'] + +[tool.ruff.format] +quote-style = 'single' + +[tool.ruff.lint.isort] +known-first-party = ['test'] + +# Wrap lines to 100 chars, but don't error on unwrappable lines until 120 chars +[tool.ruff.lint.pycodestyle] +max-line-length = 120 diff --git a/test/controllers/test_observation_controller.py b/test/controllers/test_observation_controller.py index 96decea5..8bc2bfe2 100644 --- a/test/controllers/test_observation_controller.py +++ b/test/controllers/test_observation_controller.py @@ -1,4 +1,4 @@ -# ruff: noqa: F405 +# ruff: noqa: F403, F405 from datetime import datetime from io import BytesIO from unittest.mock import patch diff --git a/test/sample_data.py b/test/sample_data.py index be1fe053..7184e6cf 100644 --- a/test/sample_data.py +++ b/test/sample_data.py @@ -1,4 +1,4 @@ -"Sample responses representing different variations on all supported resource types" +'Sample responses representing different variations on all supported resource types' # ruff: noqa: F401, F403 import json from glob import glob diff --git a/test/sample_data/get_observations_by_id.py b/test/sample_data/get_observations_by_id.py index 8a3f5546..6e07f35d 100644 --- a/test/sample_data/get_observations_by_id.py +++ b/test/sample_data/get_observations_by_id.py @@ -3,10 +3,10 @@ from dateutil.tz import tzoffset { - "total_results": 1, - "page": 1, - "per_page": 1, - "results": [ + 'total_results': 1, + 'page': 1, + 'per_page': 1, + 'results': [ { 'id': 16227955, 'annotations': [ diff --git a/test/sample_data/get_taxa_autocomplete_minified.py b/test/sample_data/get_taxa_autocomplete_minified.py index 1652f17f..cfadb986 100644 --- a/test/sample_data/get_taxa_autocomplete_minified.py +++ b/test/sample_data/get_taxa_autocomplete_minified.py @@ -1,12 +1,12 @@ [ - " 52747: Family Vespidae (Hornets, Paper Wasps, Potter Wasps, and Allies)", - " 84738: Subfamily Vespinae (Hornets and Yellowjackets)", - " 131878: Species Nicrophorus vespillo (Vespillo Burying Beetle)", - " 621585: Species Vespicula trachinoides (Vespicula Waspfish)", - " 495392: Species Vespidae st1", - " 70118: Species Nicrophorus vespilloides (Lesser Vespillo Burying Beetle)", - " 92786: Genus Vespicula", - " 646195: Genus Vespiodes", - " 621584: Species Vespicula cypho", - " 621586: Species Vespicula zollingeri", + ' 52747: Family Vespidae (Hornets, Paper Wasps, Potter Wasps, and Allies)', + ' 84738: Subfamily Vespinae (Hornets and Yellowjackets)', + ' 131878: Species Nicrophorus vespillo (Vespillo Burying Beetle)', + ' 621585: Species Vespicula trachinoides (Vespicula Waspfish)', + ' 495392: Species Vespidae st1', + ' 70118: Species Nicrophorus vespilloides (Lesser Vespillo Burying Beetle)', + ' 92786: Genus Vespicula', + ' 646195: Genus Vespiodes', + ' 621584: Species Vespicula cypho', + ' 621586: Species Vespicula zollingeri', ] diff --git a/test/test_converters.py b/test/test_converters.py index be915e9e..b47c60b0 100644 --- a/test/test_converters.py +++ b/test/test_converters.py @@ -144,7 +144,7 @@ def test_convert_observation_timestamps( @pytest.mark.parametrize( 'input, expected_output', - [(None, (0, 0)), ((1, 1), (1, 1)), ({"width": 1600, "height": 1200}, (1600, 1200))], + [(None, (0, 0)), ((1, 1), (1, 1)), ({'width': 1600, 'height': 1200}, (1600, 1200))], ) def test_format_dimensions(input, expected_output): assert format_dimensions(input) == expected_output diff --git a/test/test_formatters.py b/test/test_formatters.py index 9b49c7d1..06c08d2b 100644 --- a/test/test_formatters.py +++ b/test/test_formatters.py @@ -1,4 +1,4 @@ -# ruff: noqa: E501, F405 +# ruff: noqa: E501, F403, F405 import re from copy import deepcopy from io import StringIO diff --git a/test/test_models.py b/test/test_models.py index 0e2c674e..e8a30568 100644 --- a/test/test_models.py +++ b/test/test_models.py @@ -1,3 +1,4 @@ +# ruff: noqa: F403 # TODO: Move most of these test cases to controller tests """Things to test for each model: diff --git a/test/test_session.py b/test/test_session.py index c4736fa0..7f90f76a 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -160,7 +160,7 @@ def test_request_validate_json__retry_success(requests_mock): # Expect valid JSON on the second attempt session = ClientSession(max_retries=7) response = session.get('http://url/maybe_valid_json', refresh=True) - assert response.json() == {"results": "valid response"} + assert response.json() == {'results': 'valid response'} def test_session__cache_file():