-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Re-enable mypy and sync mypy.ini from skeleton #4604
Conversation
The "Fix ConfigHandler generic" commit is related to python/mypy#17631 (comment) (same symptoms). Not sure why it wasn't failing before, didn't fail locally (granted I'm running from Windows on 3.9, so it could be environment-specific, despite version/platform flags), and only failed on the CI on (MacOS and/or 3.12)1. But it still revealed an underlying misuse of the Footnotes
|
I still see some test failures.
What's the plan for those? Also, thanks for reconciling the differences between setuptools' and skeleton's mypy.ini. |
I rebase and fix them 😃 |
setuptools/config/expand.py
Outdated
# TODO: Explain why passing None is fine here when ConfigParser.default_section expects to be str | ||
parser = ConfigParser(default_section=None, delimiters=("=",)) # type: ignore[call-overload] |
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 this be ?
# TODO: Explain why passing None is fine here when ConfigParser.default_section expects to be str | |
parser = ConfigParser(default_section=None, delimiters=("=",)) # type: ignore[call-overload] | |
parser = ConfigParser(default_section="", delimiters=("=",)) |
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.
The meaning of default_section
is documented here. It suggests that the default section could be overridden from the default of "DEFAULT"
.
I don't know why the original author passed default_section=None
. Reading briefly through the configparser code, it looks like the default_section
is often compared for equality, so None
is effectively treated as "no default". Presumably that was the intention of this usage.
Probably what should happen here is configparser should be explicit about what types are allowed here. I scanned through the configparser tests, but didn't see anything that explicitly allowed or excluded None
as a valid type, and since None
appears to be valid per this usage, it's probably more accurately an Any
or Hashable
type.
My recommendation - file a ticket with python/cpython (or python/typeshed) indicating that the type spec for this parameter is ambiguous and should be refined, and then link that issue here instead of a TODO (since there's nothing "to do" in setuptools until such a refinement is present).
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.
The author being @abravalheri in https://github.com/pypa/setuptools/pull/3067/files#diff-2e8e2332e00f145022b07f1a5de895e643f38570a1765bd2da26e27fe29b64cdR305 I'll ask even if that was a couple years ago :)
Do you remember if there was any reason to set ConfigParser
's default_section
to None
instead of using the default of "DEFAULT"
? (re-exported as configparser.DEFAULTSECT
)
(I'm still gonna go ask whether using None is a valid usage. Seemingly to avoid having default sections)
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.
In the mean time, I marked setuptool's usage as undocumented behaviour, linking to his issue/question I created: python/typeshed#12700
Further actions can come in a follow-up PR once the question is resolved and an action has been taken.
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.
Do you remember if there was any reason to set
ConfigParser
'sdefault_section
toNone
instead of using the default of"DEFAULT"
? (re-exported asconfigparser.DEFAULTSECT
)
I believe I was trying to achieve the behaviour described by Jason, i.e. "no default".
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.
@abravalheri Thanks. This confirms what we thought. I think the new comment of calling this out as undocumented behaviour but not changing it is probably fine.
170c2c0
to
377cd71
Compare
@@ -1418,7 +1418,7 @@ def VCRuntimeRedist(self) -> str | None: | |||
os.path.join(prefix, arch_subdir, crt_dir, vcruntime) | |||
for (prefix, crt_dir) in itertools.product(prefixes, crt_dirs) | |||
) | |||
return next(filter(os.path.isfile, candidate_paths), None) | |||
return next(filter(os.path.isfile, candidate_paths), None) # type: ignore[arg-type] #python/mypy#12682 |
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.
377cd71
to
fb95489
Compare
fb95489
to
3f05bb9
Compare
@jaraco Bump on this since currently static typing validation from mypy is disabled (at least pyright's running). And some of my pending PRs should be validated by 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.
LGTM. Just a couple lingering concerns.
setuptools/config/expand.py
Outdated
# TODO: Explain why passing None is fine here when ConfigParser.default_section expects to be str | ||
parser = ConfigParser(default_section=None, delimiters=("=",)) # type: ignore[call-overload] |
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.
The meaning of default_section
is documented here. It suggests that the default section could be overridden from the default of "DEFAULT"
.
I don't know why the original author passed default_section=None
. Reading briefly through the configparser code, it looks like the default_section
is often compared for equality, so None
is effectively treated as "no default". Presumably that was the intention of this usage.
Probably what should happen here is configparser should be explicit about what types are allowed here. I scanned through the configparser tests, but didn't see anything that explicitly allowed or excluded None
as a valid type, and since None
appears to be valid per this usage, it's probably more accurately an Any
or Hashable
type.
My recommendation - file a ticket with python/cpython (or python/typeshed) indicating that the type spec for this parameter is ambiguous and should be refined, and then link that issue here instead of a TODO (since there's nothing "to do" in setuptools until such a refinement is present).
c094ab8
to
160f697
Compare
160f697
to
9c1fce9
Compare
Other PRs started failing too with a strange error (not the same though), so CI failure may or may not be related to these changes (although I don't see which of my changes could cause it) |
fbdb2b2
to
ec54219
Compare
Now that the weird CI issue seems resolved. I'd like to merge this before bumping mypy to 1.12. And to unblock #4504 |
ec54219
to
cec7374
Compare
cec7374
to
1429bf5
Compare
Summary of changes
Ref jaraco/skeleton#143
Pull Request Checklist
newsfragments/
.(See documentation for details)