Skip to content

Commit cb7ad25

Browse files
committed
Merge branch 'master' into feature/bbox-validation
2 parents a148f8d + 613bd1b commit cb7ad25

File tree

10 files changed

+74
-42
lines changed

10 files changed

+74
-42
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.6.0a0
2+
current_version = 0.6.1
33
commit = True
44
tag = True
55
tag_name = {new_version}

.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

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [0.6.1] - 2023-05-12
9+
10+
### Fixed
11+
12+
* Fix issue with null bbox validation (author @bmschmidt, https://github.com/developmentseed/geojson-pydantic/pull/119)
13+
14+
## [0.6.0] - 2023-05-09
15+
16+
No change since 0.6.0a0
17+
818
## [0.6.0a0] - 2023-04-04
919

1020
### Added
@@ -268,8 +278,10 @@ Although the type file was added in `0.2.0` it wasn't included in the distribute
268278
### Added
269279
- Initial Release
270280

271-
[unreleased]: https://github.com/developmentseed/geojson-pydantic/compare/0.6.0a...HEAD
272-
[0.6.0a]: https://github.com/developmentseed/geojson-pydantic/compare/0.5.0...0.6.0a
281+
[unreleased]: https://github.com/developmentseed/geojson-pydantic/compare/0.6.1...HEAD
282+
[0.6.1]: https://github.com/developmentseed/geojson-pydantic/compare/0.6.0...0.6.1
283+
[0.6.0]: https://github.com/developmentseed/geojson-pydantic/compare/0.6.0a0...0.6.0
284+
[0.6.0a]: https://github.com/developmentseed/geojson-pydantic/compare/0.5.0...0.6.0a0
273285
[0.5.0]: https://github.com/developmentseed/geojson-pydantic/compare/0.4.3...0.5.0
274286
[0.4.3]: https://github.com/developmentseed/geojson-pydantic/compare/0.4.2...0.4.3
275287
[0.4.2]: https://github.com/developmentseed/geojson-pydantic/compare/0.4.1...0.4.2

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ To run the tests, first install the package in a virtual environment:
55
```sh
66
virtualenv venv
77
source venv/bin/activate
8-
pip install -e '.[test]'
8+
python -m pip install -e '.[test]'
99
```
1010

1111
You can then run the tests with the following command:

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<img src="https://img.shields.io/github/license/developmentseed/geojson-pydantic.svg" alt="License">
2121
</a>
2222
<a href="https://anaconda.org/conda-forge/geojson-pydantic" target="_blank">
23-
<img src="https://anaconda.org/conda-forge/geojson-pydantic/badges/installer/conda.svg" alt="Conda">
23+
<img src="https://anaconda.org/conda-forge/geojson-pydantic/badges/version.svg" alt="Conda">
2424
</a>
2525
</p>
2626

@@ -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/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Polygon,
1212
)
1313

14-
__version__ = "0.6.0a0"
14+
__version__ = "0.6.1"
1515

1616
__all__ = [
1717
"Feature",

geojson_pydantic/geometries.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def __wkt_coordinates__(self, coordinates: Any, force_z: bool) -> str:
188188
@validator("coordinates")
189189
def check_closure(cls, coordinates: List) -> List:
190190
"""Validate that Polygon is closed (first and last coordinate are the same)."""
191-
if any([ring[-1] != ring[0] for ring in coordinates]):
191+
if any(ring[-1] != ring[0] for ring in coordinates):
192192
raise ValueError("All linear rings have the same start and end coordinates")
193193

194194
return coordinates
@@ -241,7 +241,7 @@ def has_z(self) -> bool:
241241
@validator("coordinates")
242242
def check_closure(cls, coordinates: List) -> List:
243243
"""Validate that Polygon is closed (first and last coordinate are the same)."""
244-
if any([ring[-1] != ring[0] for polygon in coordinates for ring in polygon]):
244+
if any(ring[-1] != ring[0] for polygon in coordinates for ring in polygon):
245245
raise ValueError("All linear rings have the same start and end coordinates")
246246

247247
return coordinates
@@ -303,7 +303,7 @@ def check_geometries(cls, geometries: List) -> List:
303303
warnings.warn(
304304
"GeometryCollection should not be used for nested GeometryCollections."
305305
)
306-
if len(set(geom.type for geom in geometries)) == 1:
306+
if len({geom.type for geom in geometries}) == 1:
307307
warnings.warn(
308308
"GeometryCollection should not be used for homogeneous collections."
309309
)

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"]

tests/test_features.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def test_bad_feature_id(id):
213213
def test_feature_validation():
214214
"""Test default."""
215215
assert Feature(type="Feature", properties=None, geometry=None)
216+
assert Feature(type="Feature", properties=None, geometry=None, bbox=None)
216217

217218
with pytest.raises(ValidationError):
218219
# should be type=Feature
@@ -230,6 +231,13 @@ def test_feature_validation():
230231
# missing geometry
231232
Feature(type="Feature", properties=None)
232233

234+
assert Feature(
235+
type="Feature", properties=None, bbox=(0, 0, 100, 100), geometry=None
236+
)
237+
assert Feature(
238+
type="Feature", properties=None, bbox=(0, 0, 0, 100, 100, 100), geometry=None
239+
)
240+
233241
with pytest.raises(ValidationError):
234242
# bad bbox2d
235243
Feature(type="Feature", properties=None, bbox=(100, 100, 0, 0), geometry=None)

0 commit comments

Comments
 (0)