Skip to content

Commit

Permalink
Repeat updates to main (Py2/3) branch.
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesParrott committed Sep 19, 2024
1 parent 2778fc0 commit 30f18e3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ jobs:
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1

pylint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: install Pylint and plugin
run: |
python -m pip install --upgrade pip
pip install pytest pylint pylint-per-file-ignores
- name: run Pylint for errors and warnings only, on test_shapefile.py
run: |
pylint --disable=R,C test_shapefile.py
run_tests:
strategy:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ In the same folder as README.md and shapefile.py, from the command line run
$ python shapefile.py
```

Linux/Mac and similar platforms will need to run `$ dos2unix README.md` in order
Linux/Mac and similar platforms may need to run `$ dos2unix README.md` in order
to correct line endings in README.md.

# Contributors
Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,25 @@ skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"



[tool.pylint.MASTER]
load-plugins=[
"pylint_per_file_ignores",
]

[tool.pylint.'MESSAGES CONTROL']
# Silence warning: shapefile.py:2076:20: W0212: Access to a protected
# member _from_geojson of a client class (protected-access)
#
# Silence warnings: test_shapefile.py:{783,786,799,803,06,1195}:19:
# W0212: Access to a protected member _offsets of a
# client class (protected-access)
#
# Toml multi-line string used instead of array due to:
# https://github.com/christopherpickering/pylint-per-file-ignores/issues/160
per-file-ignores = """
shapefile.py:W0212
test_shapefile.py:W0212
"""
2 changes: 1 addition & 1 deletion requirements.test.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pytest
pytest >= 3.7
setuptools
18 changes: 9 additions & 9 deletions test_shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def test_empty_shape_geo_interface():
"""
shape = shapefile.Shape()
with pytest.raises(Exception):
shape.__geo_interface__
getattr(shape, "__geo_interface__")


@pytest.mark.parametrize("typ,points,parts,expected", geo_interface_tests)
Expand Down Expand Up @@ -486,14 +486,14 @@ def test_reader_url():
# test with extension
url = "https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/ne_110m_admin_0_tiny_countries.shp?raw=true"
with shapefile.Reader(url) as sf:
for recShape in sf.iterShapeRecords():
for __recShape in sf.iterShapeRecords():
pass
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True

# test without extension
url = "https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/ne_110m_admin_0_tiny_countries?raw=true"
with shapefile.Reader(url) as sf:
for recShape in sf.iterShapeRecords():
for __recShape in sf.iterShapeRecords():
pass
assert len(sf) > 0
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
Expand All @@ -507,7 +507,7 @@ def test_reader_url():
# test reading zipfile from url
url = "https://github.com/JamesParrott/PyShp_test_shapefile/raw/main/gis_osm_natural_a_free_1.zip"
with shapefile.Reader(url) as sf:
for recShape in sf.iterShapeRecords():
for __recShape in sf.iterShapeRecords():
pass
assert len(sf) > 0
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
Expand All @@ -519,7 +519,7 @@ def test_reader_zip():
"""
# test reading zipfile only
with shapefile.Reader("shapefiles/blockgroups.zip") as sf:
for recShape in sf.iterShapeRecords():
for __recShape in sf.iterShapeRecords():
pass
assert len(sf) > 0
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
Expand All @@ -533,7 +533,7 @@ def test_reader_zip():
with shapefile.Reader(
"shapefiles/blockgroups_multishapefile.zip/blockgroups2.shp"
) as sf:
for recShape in sf.iterShapeRecords():
for __recShape in sf.iterShapeRecords():
pass
assert len(sf) > 0
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
Expand All @@ -542,7 +542,7 @@ def test_reader_zip():
with shapefile.Reader(
"shapefiles/blockgroups_multishapefile.zip/blockgroups2"
) as sf:
for recShape in sf.iterShapeRecords():
for __recShape in sf.iterShapeRecords():
pass
assert len(sf) > 0
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
Expand Down Expand Up @@ -1032,7 +1032,7 @@ def test_reader_offsets():
# shx offsets should not be read during loading
assert not sf._offsets
# reading a shape index should trigger reading offsets from shx file
__shape = sf.shape(3)
sf.shape(3)
assert len(sf._offsets) == len(sf.shapes())


Expand All @@ -1049,7 +1049,7 @@ def test_reader_offsets_no_shx():
assert not sf._offsets
# reading a shape index should iterate to the shape
# but the list of offsets should remain empty
__shape = sf.shape(3)
sf.shape(3)
assert not sf._offsets
# reading all the shapes should build the list of offsets
shapes = sf.shapes()
Expand Down

0 comments on commit 30f18e3

Please sign in to comment.