-
Notifications
You must be signed in to change notification settings - Fork 180
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
[MRG] Update hide_modules.py #852
Conversation
Remove deprecated importlib.abc.Finder
pynetdicom/tests/hide_modules.py
Outdated
import importlib.abc | ||
|
||
# py>=3.3 has MetaPathFinder | ||
_ModuleHiderBase = getattr(importlib.abc, "MetaPathFinder", importlib.abc.Finder) | ||
_ModuleHiderBase = getattr(importlib.abc, "MetaPathFinder") | ||
except ImportError: | ||
# py2 | ||
_ModuleHiderBase = object |
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.
While at it, you can remove this try/except, which was only needed for Python 2 compatibility, and directly access the attribute instead of using getattr
.
It would also make sense to add tests for Python 3.12-dev (and 3.11, for that matter) in merge-pytest.yaml
to see this kind of problems in the future.
Codecov Report
@@ Coverage Diff @@
## master #852 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 28 28
Lines 8639 8639
=========================================
Hits 8639 8639 |
Remove try catch for Python 2
pynetdicom/tests/hide_modules.py
Outdated
import importlib.abc | ||
|
||
# py>=3.3 has MetaPathFinder | ||
_ModuleHiderBase = getattr(importlib.abc, "MetaPathFinder") |
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.
Why still use getattr
? Actually, this variable should not be needed anymore, just use
from importlib.abc import MetaPathFinder
class ModuleHider(MetaPathFinder):
...
class ModuleHider(MetaPathFinder):
pynetdicom/tests/hide_modules.py
Outdated
|
||
|
||
class ModuleHider(_ModuleHiderBase): | ||
class ModuleHider(MetaPathFinder):: |
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.
Typo - double colon.
Can you also please add 3.11 and 3.12-dev to the CI tests as mentioned above?
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.
Uh, how to add 3.11 and 3.12-dev to the CI tests?
Sorry but I'm not very well versed to development, git and so on
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.
Ok, I can just do it myself if you don't mind.
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.
Just did it - I hope you don't mind...
I prefer the approach in #853, wrapping getattr in |
Why would you prefer And I closed your PR only because it was a duplicate, not because I did not like it :) |
Well, Of course that could be done without
No hard feelings. I should have looked better before submitting my PR. I'm not asking you to use it. It's up to you to decide on the final fix. Removing leftover cruft from 2.x ages is probably a good idea. With the simple(r) patch from #853 everything is working again in Fedora. Next release we'll take whatever you provide. 😉 |
Thats true, but that usage has been deprecated for quite some time, and using |
- fix syntax in last change
- add release note
I'm going to merge now - some test is randomly failing, this is handled in another issue. |
Remove deprecated importlib.abc.Finder
Reference issue
#851