Skip to content

Commit

Permalink
Merge pull request #532 from pyinat/ruff
Browse files Browse the repository at this point in the history
Use ruff for code formatting
  • Loading branch information
JWCook committed Dec 12, 2023
2 parents 6bf9718 + cfd990f commit 240d0fb
Show file tree
Hide file tree
Showing 15 changed files with 388 additions and 373 deletions.
29 changes: 9 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ This isn't needed for internal changes (tests, other docs, refactoring, etc.).
All parameters and return values should have type annotations, which will be checked by `mypy` and
will show up in the documentation.

### Formatting, Linting, Type Checking, Etc.
### Linting & Formatting
Code checking and formatting tools used include:
* [black](https://github.com/psf/black)
* [isort](https://pycqa.github.io/isort/)
* [flake8](https://flake8.pycqa.org/en/latest/)
* [ruff (linter)](https://docs.astral.sh/ruff/linter)
* [ruff (formatter)](https://docs.astral.sh/ruff/formatter)
* [mypy](https://mypy.readthedocs.io/en/stable/getting_started.html)

All of these will be run by GitHub Actions on pull requests. You can also run them locally with:
Expand Down
2 changes: 1 addition & 1 deletion pyinaturalist/controllers/place_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyinaturalist/controllers/project_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def add_observations(
project_id=project_id,
observation_id=observation_id,
auth=True,
**params
**params,
)
responses.append(response)
return responses
Expand Down
4 changes: 2 additions & 2 deletions pyinaturalist/docs/model_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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


Expand Down
Loading

0 comments on commit 240d0fb

Please sign in to comment.