Skip to content

Conversation

@berkerpeksag
Copy link
Member

@berkerpeksag berkerpeksag commented Nov 23, 2017

The Distribution class now explicitly raises an
exception when 'classifiers', 'keywords' and
'platforms' fields are not specified as a list.

https://bugs.python.org/issue19610

The Distribution class now explicitly raises an
exception when 'classifiers', 'keywords' and
'platforms' fields are not specified as a list.
@cryvate
Copy link
Contributor

cryvate commented Nov 23, 2017

LGTM code + docs.

Is there a test that qualifiers cannot be a string? Might be a good way to make sure this isn't accidentally added, contradicting the docs.

@berkerpeksag
Copy link
Member Author

Quoting @cryvate:

Is there a test that qualifiers cannot be a string? Might be a good way to make sure this isn't accidentally added, contradicting the docs.

Do you mean is there a test for fields other than keywords, platforms and classifiers? Distribution.finalize_options() only converts a string to a list for keywords and platforms fields:

for attr in ('keywords', 'platforms'):
value = getattr(self.metadata, attr)
if value is None:
continue
if isinstance(value, str):
value = [elm.strip() for elm in value.split(',')]
setattr(self.metadata, attr, value)

@cryvate
Copy link
Contributor

cryvate commented Nov 23, 2017 via email

@berkerpeksag
Copy link
Member Author

There is no "string to list" test but "tuple to list" test for classifiers: test_classifier_invalid_type

I think that covers the following branch:

if not isinstance(value, list):
    ...

And since the implicit "string to list" conversation only happens for 'keywords' and 'platforms' fields, I think we're good to go.

Please feel free to send another PR or an example if I misunderstand your comment, thanks!

@berkerpeksag berkerpeksag merged commit dcaed6b into python:master Nov 23, 2017
@berkerpeksag berkerpeksag deleted the 19610-distutils branch November 23, 2017 18:34
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.

5 participants