Skip to content

_CField as a generic descriptor protocol - #10595

Merged
srittau merged 5 commits into
python:mainfrom
junkmd:c_field_as_descriptor
Sep 1, 2023
Merged

_CField as a generic descriptor protocol#10595
srittau merged 5 commits into
python:mainfrom
junkmd:c_field_as_descriptor

Conversation

@junkmd

Copy link
Copy Markdown
Contributor

Please see #10567

@github-actions

This comment has been minimized.

@junkmd

Copy link
Copy Markdown
ContributorAuthor

Should I consider adding workarounds for the error that raises when combining stubs/pyserial/serial/win32.pyi with Pyright?

For example, using something like _CField[Any, Any, Any].

error: Expected type arguments for generic class "_CField"
(reportMissingTypeArgument)
see python#10595
@github-actions

This comment has been minimized.

@junkmd

Copy link
Copy Markdown
ContributorAuthor

Should I consider adding workarounds for the error that raises when combining stubs/pyserial/serial/win32.pyi with Pyright?

For example, using something like _CField[Any, Any, Any].

I added workarounds.

@srittau

Copy link
Copy Markdown
Collaborator

Thanks! I assume many of the _CField[Any, Any, Any] annotations could be improved in the future? In that case, please use Incomplete (from _typeshed) instead of Any to mark that fact.

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

AutoSplit (https://github.com/Toufool/AutoSplit)
+ src/utils.py:104:26: error: Redundant cast to "int" [redundant-cast]+ src/utils.py:105:25: error: Redundant cast to "int" [redundant-cast]+ src/utils.py:106:20: error: Redundant cast to "int" [redundant-cast]+ src/utils.py:107:21: error: Redundant cast to "int" [redundant-cast]

@junkmd

Copy link
Copy Markdown
ContributorAuthor

@srittau

It's good catch. Thank you.

please use Incomplete (from _typeshed) instead of Any to mark

I did that.

@srittausrittau 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.

My ctypes knowledge is limited, but this looks like an improvement to me and primer output also looks good.

@srittau
srittau merged commit 4009efa into python:mainSep 1, 2023
@junkmd
junkmd deleted the c_field_as_descriptor branch September 1, 2023 14:29
@AlexWaygoodAlexWaygood mentioned this pull request Sep 15, 2023
Sign up for freeto 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

@junkmd@srittau