Skip to content

Commit 51f2259

Browse files
committed
switch to ruff
1 parent 26e8beb commit 51f2259

File tree

5 files changed

+46
-34
lines changed

5 files changed

+46
-34
lines changed

.flake8

Lines changed: 0 additions & 4 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
repos:
2+
- repo: https://github.com/abravalheri/validate-pyproject
3+
rev: v0.12.1
4+
hooks:
5+
- id: validate-pyproject
6+
27
- repo: https://github.com/psf/black
38
rev: 22.12.0
49
hooks:
@@ -11,19 +16,11 @@ repos:
1116
- id: isort
1217
language_version: python
1318

14-
- repo: https://github.com/PyCQA/flake8
15-
rev: 6.0.0
19+
- repo: https://github.com/charliermarsh/ruff-pre-commit
20+
rev: v0.0.238
1621
hooks:
17-
- id: flake8
18-
language_version: python
19-
20-
- repo: https://github.com/PyCQA/pydocstyle
21-
rev: 6.1.1
22-
hooks:
23-
- id: pydocstyle
24-
language_version: python
25-
additional_dependencies:
26-
- toml
22+
- id: ruff
23+
args: ["--fix"]
2724

2825
- repo: https://github.com/pre-commit/mirrors-mypy
2926
rev: v0.991
@@ -32,9 +29,5 @@ repos:
3229
language_version: python
3330
# No reason to run if only tests have changed. They intentionally break typing.
3431
exclude: tests/.*
35-
# Pass mypy the entire folder because a change in one file can break others.
36-
args: [--config-file=pyproject.toml, geojson_pydantic/]
37-
# Don't pass it the individual filenames because it is already doing the whole folder.
38-
pass_filenames: false
3932
additional_dependencies:
40-
- pydantic
33+
- pydantic

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
## Install
3232

3333
```bash
34-
$ pip install -U pip
35-
$ pip install geojson-pydantic
34+
$ python -m pip install -U pip
35+
$ python -m pip install geojson-pydantic
3636
```
3737

3838
Or install from source:
3939

4040
```bash
41-
$ pip install -U pip
42-
$ pip install git+https://github.com/developmentseed/geojson-pydantic.git
41+
$ python -m pip install -U pip
42+
$ python -m pip install git+https://github.com/developmentseed/geojson-pydantic.git
4343
```
4444

4545
Install with conda from [`conda-forge`](https://anaconda.org/conda-forge/geojson-pydantic):

geojson_pydantic/geometries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def check_geometries(cls, geometries: List) -> List:
298298
warnings.warn(
299299
"GeometryCollection should not be used for nested GeometryCollections."
300300
)
301-
if len(set(geom.type for geom in geometries)) == 1:
301+
if len({geom.type for geom in geometries}) == 1:
302302
warnings.warn(
303303
"GeometryCollection should not be used for homogeneous collections."
304304
)

pyproject.toml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,50 @@ exclude = [
4545
"CONTRIBUTING.md",
4646
]
4747

48+
[tool.coverage.run]
49+
branch = true
50+
parallel = true
51+
52+
[tool.coverage.report]
53+
exclude_lines = [
54+
"no cov",
55+
"if __name__ == .__main__.:",
56+
"if TYPE_CHECKING:",
57+
]
58+
4859
[tool.isort]
4960
profile = "black"
5061
known_first_party = ["geojson_pydantic"]
5162
known_third_party = ["pydantic"]
5263
default_section = "THIRDPARTY"
5364

5465
[tool.mypy]
55-
plugins = [
56-
"pydantic.mypy"
57-
]
66+
plugins = ["pydantic.mypy"]
5867
disallow_untyped_calls = true
5968
disallow_untyped_defs = true
6069
disallow_incomplete_defs = true
70+
warn_untyped_fields = true
6171
warn_redundant_casts = true
6272
warn_unused_ignores = true
6373
no_implicit_optional = true
6474
show_error_codes = true
6575

66-
[tool.pydantic-mypy]
67-
warn_untyped_fields = true
76+
[tool.ruff]
77+
select = [
78+
"D1", # pydocstyle errors
79+
"E", # pycodestyle errors
80+
"W", # pycodestyle warnings
81+
"F", # flake8
82+
"C", # flake8-comprehensions
83+
"B", # flake8-bugbear
84+
]
85+
ignore = [
86+
"E501", # line too long, handled by black
87+
"B008", # do not perform function calls in argument defaults
88+
"B905", # ignore zip() without an explicit strict= parameter, only support with python >3.10
89+
]
6890

69-
[tool.pydocstyle]
70-
select = "D1"
71-
match = "(?!test).*.py"
91+
[tool.ruff.per-file-ignores]
92+
"tests/test_geometries.py" = ["D1"]
93+
"tests/test_features.py" = ["D1"]
94+
"tests/test_package.py" = ["D1"]

0 commit comments

Comments
 (0)