-
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
Simplify simple functions by using assignments #2214
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2308b35
Simplify simple functions by using assignments
Avasam 28fb26f
Merge branch 'main' into remove-MakeMethod
Avasam a898a2f
Merge branch 'main' of https://github.com/mhammond/pywin32 into remov…
Avasam bfb6b7f
Add CHANGES
Avasam ef40ddf
Merge branch 'remove-MakeMethod' of https://github.com/Avasam/pywin32…
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,8 @@ | |
|
||
PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch] | ||
|
||
|
||
def _is_callable(obj): | ||
return isinstance(obj, (types.FunctionType, types.MethodType)) | ||
# ignore hasattr(obj, "__call__") as this means all COM objects! | ||
# ignore hasattr(obj, "__call__") as this means all COM objects! | ||
_CallableTypes = (types.FunctionType, types.MethodType) | ||
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. This is gonna be beneficial for type-checkers too! (Either that or making this function a |
||
|
||
|
||
class ScriptDispatch: | ||
|
@@ -42,7 +40,7 @@ def _dynamic_(self, name, lcid, wFlags, args): | |
# attempt to call a function | ||
try: | ||
func = getattr(self.scriptNamespace, name) | ||
if not _is_callable(func): | ||
if not isinstance(func, _CallableTypes): | ||
raise AttributeError(name) # Not a function. | ||
realArgs = [] | ||
for arg in args: | ||
|
@@ -60,7 +58,7 @@ def _dynamic_(self, name, lcid, wFlags, args): | |
# attempt to get a property | ||
try: | ||
ret = getattr(self.scriptNamespace, name) | ||
if _is_callable(ret): | ||
if isinstance(ret, _CallableTypes): | ||
raise AttributeError(name) # Not a property. | ||
except AttributeError: | ||
raise COMException(scode=winerror.DISP_E_MEMBERNOTFOUND) | ||
|
@@ -91,7 +89,7 @@ def _getdispid_(self, name, fdex): | |
func = getattr(self._obj_.scriptNamespace, str(name)) | ||
except AttributeError: | ||
raise COMException(scode=winerror.DISP_E_MEMBERNOTFOUND) | ||
# if not _is_callable(func): | ||
# if not isinstance(func, _CallableTypes): | ||
return win32com.server.policy.DynamicPolicy._getdispid_(self, name, fdex) | ||
|
||
|
||
|
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.
This really should've been removed with 9a11ef0