Skip to content

Commit 30f18e3

Browse files
committed
Repeat updates to main (Py2/3) branch.
1 parent 2778fc0 commit 30f18e3

File tree

5 files changed

+45
-11
lines changed

5 files changed

+45
-11
lines changed

.github/workflows/run_tests_and_hooks.yml .github/workflows/run_tests_hooks_and_tools.yml

+12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ jobs:
1717
- uses: actions/setup-python@v5
1818
- uses: pre-commit/[email protected]
1919

20+
pylint:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-python@v5
25+
- name: install Pylint and plugin
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install pytest pylint pylint-per-file-ignores
29+
- name: run Pylint for errors and warnings only, on test_shapefile.py
30+
run: |
31+
pylint --disable=R,C test_shapefile.py
2032
2133
run_tests:
2234
strategy:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ In the same folder as README.md and shapefile.py, from the command line run
14531453
$ python shapefile.py
14541454
```
14551455

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

14591459
# Contributors

pyproject.toml

+22
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,25 @@ skip-magic-trailing-comma = false
6464

6565
# Like Black, automatically detect the appropriate line ending.
6666
line-ending = "auto"
67+
68+
69+
70+
[tool.pylint.MASTER]
71+
load-plugins=[
72+
"pylint_per_file_ignores",
73+
]
74+
75+
[tool.pylint.'MESSAGES CONTROL']
76+
# Silence warning: shapefile.py:2076:20: W0212: Access to a protected
77+
# member _from_geojson of a client class (protected-access)
78+
#
79+
# Silence warnings: test_shapefile.py:{783,786,799,803,06,1195}:19:
80+
# W0212: Access to a protected member _offsets of a
81+
# client class (protected-access)
82+
#
83+
# Toml multi-line string used instead of array due to:
84+
# https://github.com/christopherpickering/pylint-per-file-ignores/issues/160
85+
per-file-ignores = """
86+
shapefile.py:W0212
87+
test_shapefile.py:W0212
88+
"""

requirements.test.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pytest
1+
pytest >= 3.7
22
setuptools

test_shapefile.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def test_empty_shape_geo_interface():
436436
"""
437437
shape = shapefile.Shape()
438438
with pytest.raises(Exception):
439-
shape.__geo_interface__
439+
getattr(shape, "__geo_interface__")
440440

441441

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

493493
# test without extension
494494
url = "https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/ne_110m_admin_0_tiny_countries?raw=true"
495495
with shapefile.Reader(url) as sf:
496-
for recShape in sf.iterShapeRecords():
496+
for __recShape in sf.iterShapeRecords():
497497
pass
498498
assert len(sf) > 0
499499
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
@@ -507,7 +507,7 @@ def test_reader_url():
507507
# test reading zipfile from url
508508
url = "https://github.com/JamesParrott/PyShp_test_shapefile/raw/main/gis_osm_natural_a_free_1.zip"
509509
with shapefile.Reader(url) as sf:
510-
for recShape in sf.iterShapeRecords():
510+
for __recShape in sf.iterShapeRecords():
511511
pass
512512
assert len(sf) > 0
513513
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
@@ -519,7 +519,7 @@ def test_reader_zip():
519519
"""
520520
# test reading zipfile only
521521
with shapefile.Reader("shapefiles/blockgroups.zip") as sf:
522-
for recShape in sf.iterShapeRecords():
522+
for __recShape in sf.iterShapeRecords():
523523
pass
524524
assert len(sf) > 0
525525
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
@@ -533,7 +533,7 @@ def test_reader_zip():
533533
with shapefile.Reader(
534534
"shapefiles/blockgroups_multishapefile.zip/blockgroups2.shp"
535535
) as sf:
536-
for recShape in sf.iterShapeRecords():
536+
for __recShape in sf.iterShapeRecords():
537537
pass
538538
assert len(sf) > 0
539539
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
@@ -542,7 +542,7 @@ def test_reader_zip():
542542
with shapefile.Reader(
543543
"shapefiles/blockgroups_multishapefile.zip/blockgroups2"
544544
) as sf:
545-
for recShape in sf.iterShapeRecords():
545+
for __recShape in sf.iterShapeRecords():
546546
pass
547547
assert len(sf) > 0
548548
assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
@@ -1032,7 +1032,7 @@ def test_reader_offsets():
10321032
# shx offsets should not be read during loading
10331033
assert not sf._offsets
10341034
# reading a shape index should trigger reading offsets from shx file
1035-
__shape = sf.shape(3)
1035+
sf.shape(3)
10361036
assert len(sf._offsets) == len(sf.shapes())
10371037

10381038

@@ -1049,7 +1049,7 @@ def test_reader_offsets_no_shx():
10491049
assert not sf._offsets
10501050
# reading a shape index should iterate to the shape
10511051
# but the list of offsets should remain empty
1052-
__shape = sf.shape(3)
1052+
sf.shape(3)
10531053
assert not sf._offsets
10541054
# reading all the shapes should build the list of offsets
10551055
shapes = sf.shapes()

0 commit comments

Comments
 (0)