-
Notifications
You must be signed in to change notification settings - Fork 655
Add pkg_resources compatibility fallback using importlib.metadata #6144
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
base: main
Are you sure you want to change the base?
Conversation
Greptile SummaryThis PR adds a compatibility shim to handle the deprecation and removal of Key changes:
Implementation correctness:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Test as Test Runner
participant NU as nose_utils.py
participant PR as pkg_resources
participant IM as importlib.metadata
participant Nose as nose library
Test->>NU: import nose_utils
NU->>NU: Check Python version >= 3.12
alt Python >= 3.12
NU->>NU: Create imp module shim
end
NU->>PR: try: import pkg_resources
alt pkg_resources available
PR-->>NU: Import successful
Note over NU: Use native pkg_resources
else pkg_resources not available
PR-->>NU: ImportError
NU->>IM: from importlib import metadata
NU->>NU: Create iter_entry_points(group, name)
Note over NU: Compatibility shim created
NU->>NU: Create pkg_resources module stub
NU->>NU: sys.modules["pkg_resources"] = stub
end
NU->>Nose: import nose modules
Nose->>PR: pkg_resources.iter_entry_points(...)
alt Using shim
PR->>IM: metadata.entry_points()
IM-->>PR: EntryPoints object
PR->>PR: eps.select(group=group)
alt name is not None
PR->>PR: Filter by name
end
PR-->>Nose: Return filtered results
else Using native pkg_resources
PR-->>Nose: Return entry points
end
Nose-->>Test: Nose configured with plugins
|
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.
Additional Comments (1)
-
dali/test/python/nose_utils.py, line 108-115 (link)style: The fallback to
.get()on line 115 is redundant since Python 3.10+ always has the.select()method onentry_points(). Simplify to:Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
1 file reviewed, 1 comment
- Handles pkg_resources deprecation/removal by providing a compatibility shim that uses importlib.metadata when pkg_resources is not available for nose tests Signed-off-by: Janusz Lisiecki <[email protected]>
a2ba496 to
8a1de32
Compare
Greptile's behavior is changing!From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
|
CI MESSAGE: [40620351]: BUILD STARTED |
|
CI MESSAGE: [40620351]: BUILD PASSED |
|
How about #6146 |
shim that uses importlib.metadata when pkg_resources is not available
for nose tests
Category:
Other (e.g. Documentation, Tests, Configuration)
Description:
shim that uses importlib.metadata when pkg_resources is not available
for nose tests
Additional information:
Affected modules and functionalities:
Key points relevant for the review:
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A