Skip to content

Mark the Any trick with MaybeNone in third-party stubs - #16627

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
anistark:maybenone-third-party
Oct 29, 2026
Merged

JelleZijlstra merged 1 commit into
python:mainfrom
anistark:maybenone-third-party

Conversation

@anistark

Copy link
Copy Markdown
Contributor

Closes #12822.

Replace | Any with | MaybeNone wherever the Any stands in for None in the regex, shapely, PyYAML, requests, pyserial, docutils and yt-dlp stubs, as #12855 did for the stdlib. See the Any trick.

Prepared with Claude Code.

- No change for type checkers, `MaybeNone` is an alias for `Any`
- `regex`: match groups and `split()` results, matching stdlib `re`
- `shapely`: indexed getters, `STRtree.nearest()` and `boundary`
- `PyYAML`, `requests`, `pyserial`, `docutils`: attributes that can be `None`
- `yt-dlp`: `read_stdin()`, matching `sys.stdin`

Closes python#12822
Refs python#12855
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra
JelleZijlstra merged commit 8d185c6 into python:main Oct 29, 2026
74 checks passed
@anistark
anistark deleted the maybenone-third-party branch October 29, 2026 16:12
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.

Consistently mark types with | MaybeNone whenever it is applicable

2 participants