-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add deprecation decorator and comments for pywin32 #11570
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 deprecation decorator and comments for pywin32 #11570
Conversation
@@ -233,6 +237,11 @@ def SetSystemPowerState(Suspend, Force, /) -> None: ... | |||
def SetThreadLocale(lcid, /) -> None: ... | |||
def SetTimeZoneInformation(tzi, /): ... | |||
def SetWindowLong(hwnd: int | None, offset: int, value: float, /) -> int: ... | |||
|
|||
# This method is accidentally overwritten in source, can re-introduce once fixed: | |||
# https://github.com/mhammond/pywin32/pull/2199 |
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.
NETRESOURCE = _win32typing.PyNETRESOURCE | ||
NCB = _win32typing.PyNCB | ||
# old "deprecated" names, before types could create instances. |
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.
What's weird is that it seems to be the other way around everywhere else. Where ClassType
is the reference type, and Class
is a method that creates an instance of PyClass
.
The exception to the rule I guess. 🤷
This comment has been minimized.
This comment has been minimized.
stubs/pywin32/_win32typing.pyi
Outdated
@@ -3682,7 +3706,11 @@ class PyIInternetPriority: | |||
|
|||
class PyIInternetProtocol: | |||
def Read(self, cb, /) -> None: ... | |||
def Seek(self, dlibMove: LARGE_INTEGER, dwOrigin, /) -> None: ... | |||
@overload | |||
@deprecated("Support for passing 2 integers to create a 64bit value is deprecated - pass an int instead") |
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.
@deprecated("Support for passing 2 integers to create a 64bit value is deprecated - pass an int instead") | |
@deprecated("Support for passing two ints to create a 64-bit value is deprecated; pass a single int instead") |
stubs/pywin32/_win32typing.pyi
Outdated
def ReadAt(self, ulOffset: ULARGE_INTEGER, cb, /) -> str: ... | ||
def WriteAt(self, ulOffset: ULARGE_INTEGER, data: str, /): ... | ||
@overload | ||
@deprecated("Support for passing 2 integers to create a 64bit value is deprecated - pass an int instead") |
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.
@deprecated("Support for passing 2 integers to create a 64bit value is deprecated - pass an int instead") | |
@deprecated("Support for passing two ints to create a 64-bit value is deprecated; pass a single int instead") |
stubs/pywin32/_win32typing.pyi
Outdated
@overload | ||
def ReadAt(self, ulOffset: int, cb, /) -> str: ... | ||
@overload | ||
@deprecated("Support for passing 2 integers to create a 64bit value is deprecated - pass an int instead") |
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.
@deprecated("Support for passing 2 integers to create a 64bit value is deprecated - pass an int instead") | |
@deprecated("Support for passing two ints to create a 64-bit value is deprecated; pass a single int instead") |
stubs/pywin32/_win32typing.pyi
Outdated
def UnlockRegion(self, libOffset: ULARGE_INTEGER, cb: ULARGE_INTEGER, dwLockType, /) -> None: ... | ||
def Stat(self, grfStatFlag, /) -> STATSTG: ... | ||
@overload | ||
@deprecated("Support for passing 2 integers to create a 64bit value is deprecated - pass an int instead") |
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.
@deprecated("Support for passing 2 integers to create a 64bit value is deprecated - pass an int instead") | |
@deprecated("Support for passing two ints to create a 64-bit value is deprecated; pass a single int instead") |
stubs/pywin32/_win32typing.pyi
Outdated
@overload | ||
def LockRegion(self, libOffset: int, cb: int, dwLockType, /) -> None: ... | ||
@overload | ||
@deprecated("Support for passing 2 integers to create a 64bit value is deprecated - pass an int instead") |
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.
@deprecated("Support for passing 2 integers to create a 64bit value is deprecated - pass an int instead") | |
@deprecated("Support for passing two ints to create a 64-bit value is deprecated; pass a single int instead") |
Seems like this occurs a bunch more times, please change the remaining ones too
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.
Yeah I copied the string from source (almost) verbatim. Except I replaced long
for int
, so I don't mind changing it slightly further.
stubs/pywin32/pythoncom.pyi
Outdated
@@ -69,6 +69,10 @@ def IsGatewayRegistered(iid: _win32typing.PyIID | None, /) -> int: ... | |||
def LoadRegTypeLib(iid: _win32typing.PyIID, versionMajor, versionMinor, lcid, /) -> _win32typing.PyITypeLib: ... | |||
def LoadTypeLib(libFileName: str, /) -> _win32typing.PyITypeLib: ... | |||
def MakePyFactory(iid: _win32typing.PyIID, /) -> _win32typing.PyIClassFactory: ... | |||
@deprecated("MakeIID is deprecated - please use pywintypes.IID() instead.") |
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.
@deprecated("MakeIID is deprecated - please use pywintypes.IID() instead.") | |
@deprecated("Use pywintypes.IID() instead.") |
Type checker messages should already point out the name of the function
stubs/pywin32/pythoncom.pyi
Outdated
@@ -69,6 +69,10 @@ def IsGatewayRegistered(iid: _win32typing.PyIID | None, /) -> int: ... | |||
def LoadRegTypeLib(iid: _win32typing.PyIID, versionMajor, versionMinor, lcid, /) -> _win32typing.PyITypeLib: ... | |||
def LoadTypeLib(libFileName: str, /) -> _win32typing.PyITypeLib: ... | |||
def MakePyFactory(iid: _win32typing.PyIID, /) -> _win32typing.PyIClassFactory: ... | |||
@deprecated("MakeIID is deprecated - please use pywintypes.IID() instead.") | |||
def MakeIID(iidString: str, is_bytes: bool = ..., /) -> _win32typing.PyIID: ... | |||
@deprecated("MakeTime is deprecated - please use pywintypes.Time() instead.") |
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.
@deprecated("MakeTime is deprecated - please use pywintypes.Time() instead.") | |
@deprecated("Use pywintypes.Time() instead.") |
@@ -24,6 +25,10 @@ class BaseQuery: | |||
class Query(BaseQuery): | |||
volatilecounters: Incomplete | |||
def __init__(self, *args, **namedargs) -> None: ... | |||
@deprecated( | |||
"The use of addperfcounter by end-users is deprecated, since the use of addcounterbybrowsing is considerably more flexible and general." |
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.
"The use of addperfcounter by end-users is deprecated, since the use of addcounterbybrowsing is considerably more flexible and general." | |
"Use addcounterbybrowsing instead." |
@@ -17,6 +17,12 @@ class DispatcherWin32trace(DispatcherTrace): | |||
class DispatcherOutputDebugString(DispatcherTrace): ... | |||
|
|||
class DispatcherWin32dbg(DispatcherBase): | |||
@deprecated( |
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.
Should this be on the class instead?
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.
Oh yeah you can do that! Any usage of the class (even as type hint) appears as deprecated in Pylance. Sure.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Jelle Zijlstra <[email protected]>
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
I searched and read the source for
deprecat
andobsolet
Fixed the type of some methods I touched here. All typing changes are tested.