Skip to content

[pywin32] Type pscon property keys as PyPROPERTYKEY - #16656

Merged
Avasam merged 2 commits into
python:mainfrom
RomanOdokienko:pywin32-pscon-propertykey
Oct 30, 2026
Merged

Avasam merged 2 commits into
python:mainfrom
RomanOdokienko:pywin32-pscon-propertykey

Conversation

@RomanOdokienko

Copy link
Copy Markdown
Contributor

pywin32 converts a PROPERTYKEY to and from an (IID, pid) tuple (source), and every PKEY_* constant in pscon is such a tuple (source). This makes PyPROPERTYKEY an alias for tuple[PyIID, int] and uses it for the 567 PKEY_* constants (plus int for GUIDSTRING_MAX/PKEYSTR_MAX), so the constants can be passed to propsys functions that take a PyPROPERTYKEY.

🤖 Generated with Claude Code

pywin32 represents a PROPERTYKEY as an `(IID, pid)` tuple, so make
`PyPROPERTYKEY` an alias for `tuple[PyIID, int]` and use it for the 567
`PKEY_*` constants in `win32comext.propsys.pscon`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@Avasam Avasam left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
All the *con.py modules in pywin32 are generated from Windows constants. Since you're modifying most of the module anyway, would you mind making these all as : Final (with the actual literal value whenever the linter doesn't whine)? We already do so in storagecon.pyi, win32con.pyi and isapicon.pyi if you want to see what I mean.

Use literal values for the integer constants and `Final[PyPROPERTYKEY]`
for the property keys, as in `storagecon.pyi` and `isapicon.pyi`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RomanOdokienko

Copy link
Copy Markdown
Contributor Author

Done — integer constants are now Final with their literal values, and the property keys are Final[PyPROPERTYKEY] since tuples can't be literals.

@Avasam Avasam left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

@github-actions

Copy link
Copy Markdown
Contributor

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

@Avasam
Avasam merged commit 2e4d4dc into python:main Oct 30, 2026
74 checks passed
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.

2 participants