-
-
Notifications
You must be signed in to change notification settings - Fork 97
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 type hints to comtypes/__init__.py
#364
Conversation
I know this is merged but there is a problem with how the type annotations are being done. Why are Python 2 style annotations being used? For starters these are not going to stay and are going to get removed from Python. The second thing is they are not compatible with The 3rd thing is the use of pyi files is really for c extensions where type hints cannot be read. If it's a python source file then all the type hints should be located in that source file. |
@kdschlosser this was my suggestion to keep Py2.7 compatibility for some more time. The current plan is to drop Py2.7 support in the middle of 2023 or maybe even earlier (after some release). |
It's a lot of work that is going to end up having to be redone in a year or potentially less for type hinting which hasn't been used for how many years now? I think the library will be able to get along for <= 1 year without type hints so they can be done a single time and done properly for Python 3. It is a lot of time spent to end up having it all undone in the not too distant future, Just my thoughts on it. |
In addition to what I planned in #327, I have added typehints in this format to As for comment annotations, I believe that it is not difficult to convert them to inline annotations since there are tools such as https://github.com/ilevkivskyi/com2ann. The |
related to #327
This PR introduces type hints into statically defined modules.
import
s are now grouped together at the beginning of the code.add_metaclass
, it was moved where "if it was imported fromsix
, it would be about here."typing
usingTYPE_CHECKING
, soList
,Tuple
and others are not in the runtime namespace._IUnknown_Base
, whose definition exists in runtime, is prevented from being used ingen
by add__known_symbols__
attributes to each modules for preventing unexpected symbols are imported tocomtypes.gen._xxx...
#360.AnnoField
inhints.pyi
. This can be used only underif TYPE_CHECKING
.In order to add more type annotations in the future, there are more symbols imported from
typing
than I use this time.import
part over and over.