-
Notifications
You must be signed in to change notification settings - Fork 7
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
Issue/drop pkg resources - first part #7990
Conversation
# Conflicts: # src/inmanta/agent/agent.py # src/inmanta/agent/executor.py
src/inmanta/main.py
Outdated
@@ -182,7 +182,7 @@ def get_table(header: list[str], rows: list[list[str]], data_type: Optional[list | |||
return table.draw() | |||
|
|||
|
|||
@with_plugins(iter_entry_points("inmanta.cli_plugins")) | |||
@with_plugins(importlib_metadata.entry_points(group="inmanta.cli_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.
mypy is raising a warning here:
src/inmanta/main.py:185: error: Argument 1 to "with_plugins" has incompatible type "EntryPoints"; expected "Generator[EntryPoint, None, None]" [arg-type]
I don't know how should I fix this
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.
@with_plugins(importlib_metadata.entry_points(group="inmanta.cli_plugins")) | |
@with_plugins(iter(importlib_metadata.entry_points(group="inmanta.cli_plugins"))) |
like so?
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 doesn't seem to be maintained I think it is good to figure out why it is here at all (I suspect LSM).
We may want to vendor it or find a fork if we need it.
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.
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.
We are now experiencing this error:
src/inmanta/main.py:185: error: Argument 1 to "iter" has incompatible type "EntryPoints"; expected "SupportsIter[Generator[EntryPoint, None, None]]" [arg-type]
src/inmanta/main.py:185: note: Following member(s) of "EntryPoints" have conflicts:
src/inmanta/main.py:185: note: Expected:
src/inmanta/main.py:185: note: def __iter__(self) -> Generator[EntryPoint, None, None]
src/inmanta/main.py:185: note: Got:
src/inmanta/main.py:185: note: def __iter__(self) -> Iterator[Any]
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.
yes, click-plugin is just outdated, perhaps we can vendor it?
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.
- is there a migration guide that was followed? (I don't know if it exists, didn't find it either)
src/inmanta/env.py
Outdated
class SafeRequirement(Requirement): | ||
def __init__(self, requirement_string: str) -> None: | ||
# Packaging Requirement is not able to parse requirements with comment. Therefore, we need to remove the `comment` part | ||
drop_comment = requirement_string.split("#")[0] |
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.
How does this handle the inputs
""
"#"
" # "
"#this is a comment"
src/inmanta/env.py
Outdated
# set as a marker. The line below makes sure that the "extra" marker matches. The marker is not set by | ||
# `Distribution.requires()` when the package is installed in editable mode, but setting it always doesn't make | ||
# the marker evaluation fail. | ||
environment_marker_evaluation = {"extra": contained_in_extra} if contained_in_extra else None | ||
if r.marker and not r.marker.evaluate(environment=environment_marker_evaluation): | ||
# The marker of the requirement doesn't apply on this environment | ||
continue | ||
if r.key not in installed_packages or str(installed_packages[r.key]) not in r: | ||
if ( | ||
r.name.lower() not in installed_packages |
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 is the lower
added?
src/inmanta/env.py
Outdated
@@ -234,7 +253,7 @@ def get_packages_in_working_set(cls, inmanta_modules_only: bool = False) -> dict | |||
:param inmanta_modules_only: Only return inmanta modules from the working set | |||
""" | |||
return { | |||
dist_info.key: version.Version(dist_info.version) | |||
utils.canonicalize_name(dist_info.key): version.Version(dist_info.version) |
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.
We may want to write a comment or adr about name
Vs canonicalize_name
. What should be used where.
src/inmanta/main.py
Outdated
@@ -182,7 +182,7 @@ def get_table(header: list[str], rows: list[list[str]], data_type: Optional[list | |||
return table.draw() | |||
|
|||
|
|||
@with_plugins(iter_entry_points("inmanta.cli_plugins")) | |||
@with_plugins(importlib_metadata.entry_points(group="inmanta.cli_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.
@with_plugins(importlib_metadata.entry_points(group="inmanta.cli_plugins")) | |
@with_plugins(iter(importlib_metadata.entry_points(group="inmanta.cli_plugins"))) |
like so?
src/inmanta/main.py
Outdated
@@ -182,7 +182,7 @@ def get_table(header: list[str], rows: list[list[str]], data_type: Optional[list | |||
return table.draw() | |||
|
|||
|
|||
@with_plugins(iter_entry_points("inmanta.cli_plugins")) | |||
@with_plugins(importlib_metadata.entry_points(group="inmanta.cli_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.
this doesn't seem to be maintained I think it is good to figure out why it is here at all (I suspect LSM).
We may want to vendor it or find a fork if we need it.
src/inmanta/main.py
Outdated
@@ -182,7 +182,7 @@ def get_table(header: list[str], rows: list[list[str]], data_type: Optional[list | |||
return table.draw() | |||
|
|||
|
|||
@with_plugins(iter_entry_points("inmanta.cli_plugins")) | |||
@with_plugins(importlib_metadata.entry_points(group="inmanta.cli_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.
src/inmanta/module.py
Outdated
@@ -107,7 +105,7 @@ def __init__(self, requirement: packaging.requirements.Requirement) -> None: | |||
f"Problematic case: {str(requirement)}" | |||
) | |||
self._requirement: inmanta.util.CanonicalRequirement = inmanta.util.parse_requirement(str(requirement)) | |||
self._project_name = re.sub('[^A-Za-z0-9.]+', '-', requirement.name) | |||
self._project_name = re.sub("[^A-Za-z0-9.]+", "-", requirement.name) |
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.
Maybe it would be better to only receive a string?
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.
As discussed in person
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.
As discussed
Processing this pull request |
Failed to merge changes into iso7 due to merge conflict. Please open a pull request for these branches separately by cherry-picking the commit that was made on the branch master (git cherry-pick d048e72). |
Merged into branches master in d048e72 |
# Description First part that migrates the use of the deprecated library: pkg_resources. This part preserves the venv caching mechanism that allows us to speed up the test suite. The second part should migrate this mechanism Related to #6668 # Self Check: Strike through any lines that are not applicable (`~~line~~`) then check the box - [ ] Attached issue to pull request - [ ] Changelog entry - [ ] Type annotations are present - [ ] Code is clear and sufficiently documented - [ ] No (preventable) type errors (check using make mypy or make mypy-diff) - [ ] Sufficient test cases (reproduces the bug/tests the requested feature) - [ ] Correct, in line with design - [ ] End user documentation is included or an issue is created for end-user documentation (add ref to issue here: ) - [ ] If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)
Not closing this pull request due to previously commented issues for some of the destination branches. Please open a separate pull request for those branches by cherry-picking the relevant commit. You can safely close this pull request and delete the source branch. |
This branch was not deleted as it seems to still be in use. |
# Description Implementation of #7990 for ISO7 Related to #6668 # Self Check: Strike through any lines that are not applicable (`~~line~~`) then check the box - [ ] Attached issue to pull request - [ ] Changelog entry - [ ] Type annotations are present - [ ] Code is clear and sufficiently documented - [ ] No (preventable) type errors (check using make mypy or make mypy-diff) - [ ] Sufficient test cases (reproduces the bug/tests the requested feature) - [ ] Correct, in line with design - [ ] End user documentation is included or an issue is created for end-user documentation (add ref to issue here: ) - [ ] If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)
Everything has been merged (ISO7 and master) |
Description
First part that migrates the use of the deprecated library: pkg_resources. This part preserves the venv caching mechanism that allows us to speed up the test suite. The second part should migrate this mechanism
Related to #6668
Self Check:
Strike through any lines that are not applicable (
~~line~~
) then check the box