-
Notifications
You must be signed in to change notification settings - Fork 4
Improve pylint and mypy linting by not requiring directory structure outside of repository #1
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
Improve pylint and mypy linting by not requiring directory structure outside of repository #1
Conversation
200213e
to
cc41807
Compare
Does the error happen in a clean venv or only when the |
The error happens in the venv created by nox. There's ansible-core in there, but not ansible. What's worse, sometimes it happens, sometimes it does not. I do need to use the rsync way to reproduce it though: https://github.com/ansible-community/antsibull-nox/pull/1/files#diff-998a45901c6eeed5c113b8b118eecc0a55676298af65200193c383975fd33fadR372 (or a copy). With the symlinks (that's commented in right now) there are other errors ( |
After some trial and error I found out that I don't really need the I'm currently polishing the PR and will push something soon. |
Meh, for whatever reason this seems to be hitting pylint-dev/pylint#5832... |
I also created wntrblm/nox#943 since for some reason nox runs the linting with Python 3.11 instead of 3.13. |
The way the nox actions selects Python versions is kind of wonky. Might be better to just use setup-python to install Python and then pipx or uv to run nox. |
ffb55a2
to
db617b5
Compare
db617b5
to
c882bbe
Compare
Yep, with Python 3.13 the pylint bug is gone... |
Co-authored-by: Maxwell G <[email protected]>
src/antsibull_nox/collection.py
Outdated
for namespace in root.iterdir(): | ||
try: | ||
if namespace.is_dir() or namespace.is_symlink(): | ||
for name in root.iterdir(): |
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 this supposed to iterate through root a second time?
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.
Definitely not ;-)
(And yes, we really need tests...)
copier.copy(collection.path, path, exclude_root=[".nox", ".tox"]) | ||
|
||
|
||
def _copy_collection_rsync_hard_links(collection: CollectionData, path: Path) -> None: |
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 this still needed?
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.
Right now no, but I'm thinking about offering this (or a variant of it) as an option in the future.
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 could also potentially implement this functionality as a separate Copier in antsibull_fileutils.
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.
Totally, yes.
@@ -52,8 +62,56 @@ def install(session: nox.Session, *args: str, editable: bool = False, **kwargs): | |||
session.install(*args, "-U", **kwargs) | |||
|
|||
|
|||
@dataclass | |||
class CollectionSetup: |
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.
Could you document what each of these attributes are? It's not immediately clear based on the names.
Another thing, it would be nice if something like this where dependencies are also installed in the flat structure was supported:
|
|
Co-authored-by: Maxwell G <[email protected]>
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.
Other than the exception handling, this looks good to me
src/antsibull_nox/collection.py
Outdated
name=name.name, | ||
root=root, | ||
) | ||
except: # noqa: E722, pylint: disable=bare-except |
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.
except: # noqa: E722, pylint: disable=bare-except | |
except Exception: |
at least, otherwise, this will catch KeyboardInterrupt and such. Or should this only catch ValueError because _load_collection_data_from_disk doesn't (directly) raise anything else?
(This also applies to the other callers of _load_collection_from_disk)
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.
It should also catch I/O errors if someone did something strange in that directory structure so that some other call fails.
copier.copy(collection.path, path, exclude_root=[".nox", ".tox"]) | ||
|
||
|
||
def _copy_collection_rsync_hard_links(collection: CollectionData, path: Path) -> None: |
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 could also potentially implement this functionality as a separate Copier in antsibull_fileutils.
Doesn't this code allow checking out collections without a parent |
Yes, I only misread something. |
Thanks for reviewing this, @gotmax23! |
This is currently blocked by pylint-dev/pylint#10278.