diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5d61a73..05ef568 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -92,4 +92,4 @@ Once you have explained why the PR is needed: -[^1]: Any interaction with Agents or other bots, even with the best of intentions, has exactly the same effect as feeding another prompt into the slop machine. We therefore respectfully request all users and contributers, to avoid interacting with agents and bots (other than to close or delete their PRs, and to report and block the accounts they were created from). +[^1]: Any interaction with Agents or other bots, even with the best of intentions, has exactly the same effect as feeding another prompt into the slop machine. We therefore respectfully request all users and contributors, to avoid interacting with agents and bots (other than to close or delete their PRs, and to report and block the accounts they were created from). diff --git a/README.md b/README.md index 437f9d6..c949627 100644 --- a/README.md +++ b/README.md @@ -1705,7 +1705,7 @@ including py.typed, and no longer being a single file project). - Deleted py.typed (probably temporarily). Including the py.typed marker file with a single file package caused type checkers to type check all other libraries installed in the same directory (whether they're typed or not, enforcing type checking for all the adjacent dirs libraries, regardless of the user's intentions for the type checker) (pointed out by @dl1jbe - thanks Thomas). Discussions will be started about a longer term fix, possibly e.g. possibly refactoring to a package, and restoring py.typed. ### Code quality: -- Ruff check's UP rule added (mimicks PyUpgrade) (@mwtoews). +- Ruff check's UP rule added (mimics PyUpgrade) (@mwtoews). ## 3.0.1 diff --git a/SECURITY.md b/SECURITY.md index 036d42c..ddade3d 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,7 +6,7 @@ handle it as best we can. It is in nobody's interest to attribute blame. There is no bug bounty. But one maintainer has bought people a drink before, for far less. ## Overview / attack surface - - PyShp is a pure-Python library that typically gets called from other Python code. Attackers with the ability to run Python code on a target in the first place, can already peform any function Python allows them to. As long as PyShp was not the means by which the Attacker gained the ability to run arbitrary Python code, PyShp cannot prevent this. + - PyShp is a pure-Python library that typically gets called from other Python code. Attackers with the ability to run Python code on a target in the first place, can already perform any function Python allows them to. As long as PyShp was not the means by which the Attacker gained the ability to run arbitrary Python code, PyShp cannot prevent this. - `eval`, `compile` and `exec` etc. are not used, and should be considered to be banned. - The vulnerabilities we fail to consider are even more important than those we are aware of. That said, by its very nature, PyShp does read arbitrary binary data. An attack via a maliciously crafted shapefile is possible. To mitigate this, PyShp -should- only convert arbitrary binary data into specific Python types (floats, ints, strings, booleans, dates, lists, arrays, tuples and dicts). These do contain arbitrary data, but they should never result in arbitrary code execution (or even in Python raising a non-standard system-affecting Exception or crash). - Lun (@lunuyennhi-dev) pointed out PyShp could hang if a negative .shp shape record length was encountered (more checks are now applied to these, from v3.1.7). A basic review for similar bugs has been carried out. The declared file lengths are now checked for all the constituent files. If `strict=True`, .dbf record lengths are required to match the declared field sizes. Shaperecords are already temporarily read into memory in their entirety (to minimise seeks on disk) and the numPoints field is used to form a struct fmt string used to unpack that, not for runtime control flow. Bug reports for any similar issues are more than welcome. diff --git a/changelog.txt b/changelog.txt index 51bba6f..6e572d2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -231,7 +231,7 @@ VERSION 3.0.2 2025-08-20 Code quality: - * Ruff check's UP rule added (mimicks PyUpgrade) (@mwtoews). + * Ruff check's UP rule added (mimics PyUpgrade) (@mwtoews). VERSION 3.0.1 diff --git a/pyproject.toml b/pyproject.toml index e5ddbb1..9864b46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -150,3 +150,8 @@ skip-magic-trailing-comma = false # Like Black, automatically detect the appropriate line ending. line-ending = "auto" + +[tool.codespell] +ignore-words-list = [ + "linez", +] diff --git a/src/shapefile.py b/src/shapefile.py index 993b8b2..e6c5533 100644 --- a/src/shapefile.py +++ b/src/shapefile.py @@ -370,7 +370,7 @@ def decoded_code_points_and_bytes( # Max code unit size under UTF-8, UTF-16, and UTF-32 is 4 bytes. if pad_byte == b"\x00": - # Just checking the field, in which asii spaces are technically valid + # Just checking the field, in which ascii spaces are technically valid # even though PyShp historically has converted them to underscores return BOM, {}, decoded_code_points_and_bytes([b"\x00" * N]), {} else: @@ -677,7 +677,7 @@ def from_unchecked( ) # A doctest in README.md previously passed in a string ('40') for size, - # so explictly convert name to str, and size and decimal to ints. + # so explicitly convert name to str, and size and decimal to ints. inst = cls( name=trimmed_name, field_type=type_, size=int(size), decimal=int(decimal) ) @@ -1017,7 +1017,7 @@ def itercoords() -> Iterator[PointT]: def ring_contains_ring(coords1: PointsT, coords2: list[PointT]) -> bool: - """Returns True if all vertexes in coords2 are fully inside coords1.""" + """Returns True if all vertices in coords2 are fully inside coords1.""" # Ignore Z and M values in coords2 return all(ring_contains_point(coords1, p2[:2]) for p2 in coords2) @@ -1153,7 +1153,7 @@ def organize_polygon_rings( # Could be an Enum, but an isinstance check is still needed. class _NoShapeTypeSentinel: """An instance is the default value for Shape.__init__, - to preserve old behaviour for anyone who explictly + to preserve old behaviour for anyone who explicitly called Shape(shapeType=None). """ @@ -1295,7 +1295,7 @@ def __init__( if not points or len(points) >= 2: raise ShapefileException( f"Single point Shape: {self.__class__.__name__}, shape type: {self.shapeTypeName} " - "requires one or points (and possibly a z co-ordinate and m value), not " + "requires one or points (and possibly a z coordinate and m value), not " f"lines. Got: {points=} and {lines=}" ) if lines: @@ -3186,7 +3186,7 @@ def find_deletion_flagged_records(self) -> None: @property def fields(self) -> list[Field]: - """To preserve legacy behaviour, preppend data fields with the DeletionFlag.""" + """To preserve legacy behaviour, prepend data fields with the DeletionFlag.""" return [Field("DeletionFlag", FieldType.C, 1, 0), *self.data_fields] def _record_fmt(self, fields: Container[str] | None = None) -> str: @@ -3821,7 +3821,7 @@ def iterShapes( class _NoShpSentinel: """An instance is the default value for shp to preserve the old behaviour (from when all keyword args were gathered - in the **kwargs dict) in case someone explictly + in the **kwargs dict) in case someone explicitly called Reader(shp=None) to load self.shx. """ @@ -4747,7 +4747,7 @@ def _record( value = date(*value) if isinstance(value, date): # In Pythons using certain glibc versions. - # date.strftime does not preppend zeros. + # date.strftime does not prepend zeros. str_val = value.strftime("%Y%m%d").zfill(8) # b"".join(ord(c).to_bytes() for c in s) elif value in MISSING: diff --git a/tests/run_benchmarks.py b/tests/run_benchmarks.py index 8888261..7c4f343 100644 --- a/tests/run_benchmarks.py +++ b/tests/run_benchmarks.py @@ -96,7 +96,7 @@ def write_shapefile_with_PyShp(target: str | PathLike): } # Require fields and shapeRecords to first have been populated -# from data from previouly running the reader_benchmarks +# from data from previously running the reader_benchmarks writer_benchmarks = { test_name : functools.partial( benchmark, diff --git a/uv.lock b/uv.lock index 8594b14..cf93efa 100644 --- a/uv.lock +++ b/uv.lock @@ -7,11 +7,6 @@ resolution-markers = [ "python_full_version < '3.10'", ] -[options] -exclude-newer = "0001-01-01T00:00:00Z" # This has no effect and is included for backwards compatibility when using relative exclude-newer values. -exclude-newer-span = "P1W" - - [manifest] excludes = [{ package = { name = "pre-commit" }, dependencies = ["virtualenv"] }]