Skip to content

Modernize typing.Pattern to re.Pattern[str]#162

Merged
IrishPrime merged 1 commit into
mainfrom
140/modernize-typing-pattern
May 9, 2026
Merged

Modernize typing.Pattern to re.Pattern[str]#162
IrishPrime merged 1 commit into
mainfrom
140/modernize-typing-pattern

Conversation

@IrishPrime

Copy link
Copy Markdown
Owner

typing.Pattern has been a deprecated alias for re.Pattern since Python 3.8. Switch every site in nielsen/media.py to the parameterized re.Pattern[str] form, which is documentation as well as type; it makes explicit that this project only matches against str, never bytes.

tests/test_tv.py already imports Pattern from re, so no test changes are needed.

Drive-by: tidy # TODO Do not allow non-files to # TODO: Do not allow non-files for consistency with the file's other TODO comments.

Resolve #140.

`typing.Pattern` has been a deprecated alias for `re.Pattern` since
Python 3.8. Switch every site in `nielsen/media.py` to the parameterized
`re.Pattern[str]` form, which is documentation as well as type; it makes
explicit that this project only matches against `str`, never `bytes`.

`tests/test_tv.py` already imports `Pattern` from `re`, so no test
changes are needed.

Drive-by: tidy `# TODO Do not allow non-files` to `# TODO: Do not allow
non-files` for consistency with the file's other TODO comments.

Resolve #140.
@IrishPrime IrishPrime self-assigned this May 9, 2026
@IrishPrime IrishPrime merged commit 83274af into main May 9, 2026
3 checks passed
@IrishPrime IrishPrime deleted the 140/modernize-typing-pattern branch May 9, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modernize typing.Pattern to re.Pattern[str]

1 participant