-
Notifications
You must be signed in to change notification settings - Fork 809
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
Turn on strict typing in mypy #2211
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
153a5fc
Turn on strict typing in mypy
Avasam 41e91fc
Use explicit_package_bases
Avasam d5b1422
Merge branch 'main' of https://github.com/mhammond/pywin32 into turn-…
Avasam ec6dd8f
warn_unused_ignores redundant with strict
Avasam 97e2480
Merge branch 'main' of https://github.com/mhammond/pywin32 into turn-…
Avasam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
from __future__ import annotations | ||
|
||
build_id = "306" # may optionally include a ".{patchno}" suffix. | ||
|
||
__doc__ = """This is a distutils setup-script for the pywin32 extensions. | ||
|
@@ -44,6 +46,8 @@ | |
from setuptools.command.install import install | ||
from setuptools.command.install_lib import install_lib | ||
|
||
from distutils import ccompiler | ||
from distutils._msvccompiler import MSVCCompiler | ||
from distutils.command.install_data import install_data | ||
|
||
if sys.version_info >= (3, 8): | ||
|
@@ -936,22 +940,17 @@ def my_new_compiler(**kw): | |
|
||
|
||
# No way to cleanly wedge our compiler sub-class in. | ||
from distutils import ccompiler | ||
from distutils._msvccompiler import MSVCCompiler | ||
|
||
orig_new_compiler = ccompiler.new_compiler | ||
ccompiler.new_compiler = my_new_compiler | ||
|
||
base_compiler = MSVCCompiler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't look like |
||
ccompiler.new_compiler = my_new_compiler # type: ignore[assignment] # Assuming the caller will always use only kwargs | ||
|
||
|
||
class my_compiler(base_compiler): | ||
class my_compiler(MSVCCompiler): | ||
# Just one GUIDS.CPP and it gives trouble on mainwin too. Maybe I | ||
# should just rename the file, but a case-only rename is likely to be | ||
# worse! This can probably go away once we kill the VS project files | ||
# though, as we can just specify the lowercase name in the module def. | ||
_cpp_extensions = base_compiler._cpp_extensions + [".CPP"] | ||
src_extensions = base_compiler.src_extensions + [".CPP"] | ||
_cpp_extensions = MSVCCompiler._cpp_extensions + [".CPP"] | ||
src_extensions = MSVCCompiler.src_extensions + [".CPP"] | ||
|
||
def link( | ||
self, | ||
|
@@ -1112,7 +1111,7 @@ def finalize_options(self): | |
pch_header="PyWinTypes.h", | ||
) | ||
|
||
win32_extensions = [pywintypes] | ||
win32_extensions: list[WinExt] = [pywintypes] | ||
|
||
win32_extensions.append( | ||
WinExt_win32( | ||
|
@@ -1254,11 +1253,10 @@ def finalize_options(self): | |
windows_h_ver = info[2] | ||
if len(info) > 3: | ||
sources = info[3].split() | ||
extra_compile_args = [] | ||
ext = WinExt_win32( | ||
name, | ||
libraries=lib_names, | ||
extra_compile_args=extra_compile_args, | ||
extra_compile_args=[], | ||
windows_h_version=windows_h_ver, | ||
sources=sources, | ||
) | ||
|
@@ -1425,8 +1423,8 @@ def finalize_options(self): | |
base_address=dll_base_address, | ||
) | ||
dll_base_address += 0x80000 # pythoncom is large! | ||
com_extensions = [pythoncom] | ||
com_extensions += [ | ||
com_extensions = [ | ||
pythoncom, | ||
WinExt_win32com( | ||
"adsi", | ||
libraries="ACTIVEDS ADSIID user32 advapi32", | ||
|
@@ -2089,7 +2087,7 @@ def finalize_options(self): | |
swig_include_files = "mapilib adsilib".split() | ||
|
||
|
||
def expand_modules(module_dir: Union[str, os.PathLike]): | ||
def expand_modules(module_dir: Union[str, os.PathLike[str]]): | ||
"""Helper to allow our script specifications to include wildcards.""" | ||
return [str(path.with_suffix("")) for path in Path(module_dir).rglob("*.py")] | ||
|
||
|
@@ -2104,7 +2102,7 @@ def convert_data_files(files: Iterable[str]): | |
for file in files: | ||
file = os.path.normpath(file) | ||
if file.find("*") >= 0: | ||
files_use = ( | ||
files_use = tuple( | ||
str(path) | ||
for path in Path(file).parent.rglob(os.path.basename(file)) | ||
# We never want CVS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# -*- coding: UTF-8 -*- | ||
from __future__ import annotations | ||
|
||
""" | ||
win32timezone: | ||
|
@@ -231,7 +232,6 @@ | |
datetime.datetime(2011, 11, 6, 1, 0, tzinfo=TimeZoneInfo('Pacific Standard Time')) | ||
|
||
""" | ||
from __future__ import annotations | ||
|
||
import datetime | ||
import logging | ||
|
@@ -240,6 +240,7 @@ | |
import struct | ||
import winreg | ||
from itertools import count | ||
from typing import Dict | ||
|
||
import win32api | ||
|
||
|
@@ -792,8 +793,8 @@ def get_sorted_time_zones(key=None): | |
return zones | ||
|
||
|
||
class _RegKeyDict(dict): | ||
def __init__(self, key): | ||
class _RegKeyDict(Dict[str, int]): | ||
def __init__(self, key: winreg.HKEYType): | ||
dict.__init__(self) | ||
self.key = key | ||
self.__load_values() | ||
|
@@ -907,7 +908,8 @@ def resolveMUITimeZone(spec): | |
|
||
|
||
# from jaraco.util.dictlib 5.3.1 | ||
class RangeMap(dict): | ||
# TODO: Update to implementation in jaraco.collections | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
class RangeMap(dict): # type: ignore[type-arg] # Source code is untyped :/ TODO: Add generics! | ||
""" | ||
A dictionary-like object that uses the keys as bounds for a range. | ||
Inclusion of the value for that range is determined by the | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python/typeshed#11616