-
-
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
Implement metadata validation (not used) #2817
Conversation
This needs tests and probably formatting stuff.
Mind converting it to a draft, then? So that it's visually distinctive in the PR list.. |
setuptools/dist.py
Outdated
if missing: | ||
if len(missing) == 1: | ||
message = "%s attribute" % missing[0] | ||
else: | ||
message = "%s and %s attributes" % (", ".join(missing[:-1]), | ||
missing[-1]) | ||
raise DistutilsSetupError( | ||
"Required package metadata is missing: please supply the %s." % message | ||
) |
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.
Nit: use a guard expression to dedent this.
if missing: | |
if len(missing) == 1: | |
message = "%s attribute" % missing[0] | |
else: | |
message = "%s and %s attributes" % (", ".join(missing[:-1]), | |
missing[-1]) | |
raise DistutilsSetupError( | |
"Required package metadata is missing: please supply the %s." % message | |
) | |
if not missing: | |
return | |
if len(missing) == 1: | |
message = "%s attribute" % missing[0] | |
else: | |
message = "%s and %s attributes" % (", ".join(missing[:-1]), | |
missing[-1]) | |
raise DistutilsSetupError( | |
"Required package metadata is missing: please supply the %s." % message | |
) |
Validating the user input early sounds like a good idea. The implementation seems a bit overengineered, though. |
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.
I have some ideas I'll add to the issue.
@@ -17,6 +17,7 @@ def test_bdist_rpm_warning(distutils_cmd): | |||
script_name='setup.py', | |||
script_args=['bdist_rpm'], | |||
name='foo', | |||
version='1.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.
I notice that without this change, the tests still pass. I suspect you originally intended to require both name
and version
in _validate_metadata
.
This additional code (the need for a version='1.0'
in every test, even when irrelevant to the test) feels a bit like noise.
I spent some more time looking at this today with the expectation that I'd merge it without the version requirement, but as I looked into it more, I'm far from confident that overriding
But I'm not even sure that's early enough. In theory, additional commands could alter the metadata (e.g. I'd like to avoid adding more interactions between distutils and Setuptools classes (Distribution in this case). So for now, I'd like to keep the _validate_metadata method, and defer the method of integration. |
…l missing keys as repr() of that difference.
af645e2
to
4d66083
Compare
Summary of changes
Change to the
Distribution
class to require that some metadata exists before actually doing anything.This is just a draft. It still needs test, presumably linting and formatting, and I'm not even confident that this is conceptually the right place for this logic, but I thought I'd throw this approach out there as an option for discussion.
Closes #2799, #2329
Pull Request Checklist
changelog.d/
.(See documentation for details)