Skip to content
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

WIP: Re-enable mypy and fix most issues #343

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Avasam
Copy link
Contributor

@Avasam Avasam commented Mar 12, 2025

No description provided.

Comment on lines -183 to -190
if pygments is not None:
assert len(msgs) == 0
else:
assert len(msgs) == 1
assert (
str(msgs[0][1])
== 'Cannot analyze code. Pygments package not found.'
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see pygments being use anywhere or even installed as a transitive dependency. Is that just old code ?

Comment on lines +154 to +156
# type-ignore: This makes absolutes os.Pathlike unsupported in this branch.
# Either this or we don't support bytes-based paths, or we complexify this branch.
return os.path.join(new_root, pathname[1:]) # type: ignore[index]
Copy link
Contributor Author

@Avasam Avasam Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a decision to be taken here.

  1. Don't support PathLike in this branch (current behaviour)
  2. Don't support bytes | PathLike[bytes] in this branch
Suggested change
# type-ignore: This makes absolutes os.Pathlike unsupported in this branch.
# Either this or we don't support bytes-based paths, or we complexify this branch.
return os.path.join(new_root, pathname[1:]) # type: ignore[index]
# type-ignore: This makes absolutes os.Pathlike unsupported in this branch.
# Either this or we don't support bytes-based paths, or we complexify this branch.
return os.path.join(new_root, str(pathname)[1:])
  1. Support both, requires extra checking.

Comment on lines +237 to +239
_wordchars_re = re.compile(rf'[^\\\'\"{string.whitespace} ]*')
_squote_re = re.compile(r"'(?:[^'\\]|\\.)*'")
_dquote_re = re.compile(r'"(?:[^"\\]|\\.)*"')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't exactly "heavy computing" is it? Did it need to be done lazily ?

Comment on lines +335 to +336
# TODO: Raise a more descriptive error when cmd_obj is None ?
cmd_obj = cast(Command, self.distribution.get_command_obj(command, create))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision to be taken here.

@Avasam
Copy link
Contributor Author

Avasam commented Apr 3, 2025

mypy:

distutils/_modified.py:95: error: Value of type variable "_SourcesT" of "newer_pairwise" cannot be "Iterable[str | bytes | PathLike[str] | PathLike[bytes]]" [type-var]

pyright:

distutils/_modified.py:95: Argument of type "(sources: Iterable[str | bytes | PathLike[str] | PathLike[bytes]], target: str | bytes | PathLike[str] | PathLike[bytes], missing: Literal['error', 'ignore', 'newer'] = "error") -> bool" cannot be assigned to parameter "newer" of type "(_SourcesT@newer_pairwise, _TargetsT@newer_pairwise) -> bool" in function "newer_pairwise"

@jaraco I can't help but feel this may be revealing an actual issue? Or at least an incorrect assumption.

newer_pairwise's newer param should be a function accepting a single item as the first parameter. But newer_group expects an iterable as the first parameter.
It's possible this was never raised as an issue because a str is iterable (so each character would be compared as a path, and found as inexistant)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant