One function

Boundary in zobweyt/textcase

The author described this change as fix: use `@classmethod` instead of `@staticmethod` and `TypeVar` in `Boundary.from_delimiter` for proper inheritance typing (#33). It counts as a record because the check below fails on the code as it stood at d47597d19 and passes on 3cfc56bcc, with nothing else changed between the two runs.

Fix saved2025-10-01
Sharing licenceMIT · LICENSE
Change size+3 3

What the code was meant to do, written into the code itself as a docstring

Represents a condition for splitting an identifier into words. Some boundaries, `HYPHEN`, `UNDERSCORE`, `SPACE`, and `INTERPUNCT` consume the character they split on, whereas the other boundaries do not. Examples: True False 0 1

The change

3030 length: int = 0
3131 """The length of the boundary. This is the number of graphemes that are removed when splitting."""
3232
33- @staticmethod
34- def from_delimiter(delimiter: str) -> "Boundary":
33+ @classmethod
34+ def from_delimiter(cls: type[_TBoundary], delimiter: str) -> _TBoundary:
3535 """Create a new boundary instance from a delimiter string.
3636
3737 This method makes it easier to create basic boundaries like `UNDERSCORE`, `HYPHEN`, `SPACE`, and `INTERPUNCT`.
5858 >>> DOT.length
5959 1
6060 """
61- return Boundary(match=lambda s: s.startswith(delimiter), length=len(delimiter))
61+ return cls(match=lambda s: s.startswith(delimiter), length=len(delimiter))

The check that tells the two apart

failpass·tests/boundaries/test_boundary_from_delimiter.py::test_return_type_of_custom_subclass

Check file tests/boundaries/test_boundary_from_delimiter.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itd47597d196ee286423e09041218d39c7680677a9
Broken version dated2025-10-01
Moduletextcase.__init__
Units changedBoundary
Fingerprintce753d7eea707e6a
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.