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

Add inline type annotations to statically defined modules #401

Closed
junkmd opened this issue Dec 11, 2022 · 5 comments
Closed

Add inline type annotations to statically defined modules #401

junkmd opened this issue Dec 11, 2022 · 5 comments
Labels
drop_py2 dev based on supporting only Python3, see #392 typing related to Python static typing system
Milestone

Comments

@junkmd
Copy link
Collaborator

junkmd commented Dec 11, 2022

In work related to #327, we have applied comment-type annotations to each statically defined modules.

However, those will be changed to inline annotation with the same reason as #400 and be added where they are still missing.

Inline type annotations are only available in Python 3.x and later, so the merge destination for the contributions is drop_py2 branch.

As planned in #392, we will support Python3.7 and later versions, so type hinting should be done in the way supported from 3.7 and earlier.

This kanban will be updated as the situation requires.

Any opinions would be appreciated.

@junkmd junkmd added the drop_py2 dev based on supporting only Python3, see #392 label Dec 11, 2022
@junkmd junkmd added this to the 1.3.0 milestone Dec 11, 2022
@junkmd
Copy link
Collaborator Author

junkmd commented Jan 3, 2023

As for modernizing the type annotations I added before drop_py2 plan, I am going to work on it.

The following files are targeted.

  • comtypes/__init__.py
  • comtypes/_memberspec.py
  • comtypes/automation.py
  • comtypes/client/__init__.py
  • comtypes/client/_generate.py
  • comtypes/tools/codegenerator.py
  • comtypes/tools/tlbparser.py
  • comtypes/tools/typedesc.py
  • comtypes/tools/typedesc_base.py
  • comtypes/typeinfo.py

@junkmd
Copy link
Collaborator Author

junkmd commented Jan 5, 2023

I am interested in python/typing#213.
At the moment, I'm annotating as T because the type checker can't provide the member information, even though it should be annotated as _Pointer[T] if I were to follow the implementation.

If it is accepted by the Python core developers, typing(typing_extensions), typeshed, and static type checkers would be developed assuming A & B or Intersection[A, B].

If _Pointer[T] is recognized as "pointer type and T type", we may not have to worry about workarounds for type annotations or strict inconsistencies with implementations.

@junkmd
Copy link
Collaborator Author

junkmd commented Jan 7, 2023

Changing type hints from comment annotations to inline annotations are finished. (#448, #451, #453, #444, #455, #456, #457, #459 and #461)

@junkmd
Copy link
Collaborator Author

junkmd commented May 7, 2023

memo:

python/typeshed#8968 is resolved.

So we won't have to worry about the type checker detecting false positives in the _memberspec module any more.

@junkmd
Copy link
Collaborator Author

junkmd commented Feb 5, 2024

We applied static typing to most modules with comtypes==1.3.0.

@junkmd junkmd closed this as completed Feb 5, 2024
@junkmd junkmd added the typing related to Python static typing system label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drop_py2 dev based on supporting only Python3, see #392 typing related to Python static typing system
Projects
None yet
Development

No branches or pull requests

1 participant