Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pywin32: Use PEP 570 positional-only argument syntax and fix arguments #11321

Merged
merged 5 commits into from
Jan 27, 2024

Conversation

Avasam
Copy link
Sponsor Collaborator

@Avasam Avasam commented Jan 26, 2024

The pywin32 part of #11237

Split into multiple commits for ease of review:

  1. The first commit assumes all c-extension modules are positional-only
  2. The second commit removes redundant __ prefixes
  3. For the third commit I searched the source code for all instances of PyArg_ParseTupleAndKeywords and updated all methods in the stubs that should support kwargs, and tested which ones accepted default arguments (except for methods in like 2-3 credential-related classes in _win32typing.pyi that I could figure out how to instantiate). This includes a bunch of fixes to argument order and return types I noticed along the way.

@AlexWaygood AlexWaygood changed the title Make all c-extension modules positional-only pywin32: Make all c-extension modules positional-only Jan 26, 2024
@Avasam Avasam changed the title pywin32: Make all c-extension modules positional-only pywin32: Use PEP 570 positional-only argument syntax and fix arguments Jan 26, 2024

This comment has been minimized.

@Avasam
Copy link
Sponsor Collaborator Author

Avasam commented Jan 27, 2024

That's an interesting stubtest error (at the very least the "remove leading double underscore" message should be updated):

error: win32.lib.pywintypes.error.__init__ is inconsistent, stub argument "self" should be positional or keyword (remove leading double underscore)
Stub: in file E:\Users\Avasam\Documents\Git\typeshed\stubs\pywin32\win32\lib\pywintypes.pyi:14
def (win32.lib.pywintypes.error, builtins.int, builtins.str, builtins.str)
Runtime: in file <string>
def (self, *args, **kw)

Copy link
Contributor

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

@srittau srittau merged commit 0b8841e into python:main Jan 27, 2024
45 checks passed
@Avasam Avasam deleted the pywin32-positional-only-arguments branch February 29, 2024 00:34
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