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

Don't crash if there is no description #412

Merged
merged 1 commit into from
Oct 15, 2018
Merged

Don't crash if there is no description #412

merged 1 commit into from
Oct 15, 2018

Conversation

asottile
Copy link
Contributor

@asottile asottile commented Oct 7, 2018

Resolves #411

@codecov
Copy link

codecov bot commented Oct 7, 2018

Codecov Report

Merging #412 into master will increase coverage by 0.2%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #412     +/-   ##
=========================================
+ Coverage   78.08%   78.29%   +0.2%     
=========================================
  Files          14       14             
  Lines         730      737      +7     
  Branches      104      106      +2     
=========================================
+ Hits          570      577      +7     
- Misses        127      128      +1     
+ Partials       33       32      -1
Impacted Files Coverage Δ
twine/commands/check.py 100% <100%> (ø) ⬆️
twine/wininst.py 31.57% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 360401b...125b772. Read the comment docs.

@@ -94,7 +94,7 @@ def check(dists, output_stream=sys.stdout):

# Actually render the given value
rendered = renderer.render(
metadata.get("description"), stream=stream, **parameters
metadata.get("description") or "", stream=stream, **parameters
Copy link
Member

Choose a reason for hiding this comment

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

It would be better if this was done outside of the function call.

It would further seem as though "description" may not be present and if it is present (or perhaps it is always present?) it can be None. The behaviour of metadata seems to be poorly understood by all involved, what do you think about documenting the actual behaviour here. It would be better if everyone after this point in time understood the reason for this change and why it was necessary. The comment in the test is a bit too opaque to provide that understanding.

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 was following the precedent from line 89, would you like me to change that one as well?

Copy link
Member

Choose a reason for hiding this comment

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

Please do. It's not a very good precedent.

@di
Copy link
Member

di commented Oct 9, 2018

Since all this command does right now is check if the description is valid, perhaps it should give a warning if there is no description value, rather than silently passing? It seems to me like there should be a difference between "this package has provided an empty description" and "this package has not provided a description". The user probably wants to know if the latter is happening.

@merwok
Copy link

merwok commented Oct 9, 2018

I agree with the warning or error. For example, I found this bug and PR because twine does not include long_description in generated sdists (pypa/flit#216); if twine had seemed to work I would not have seen the flit problem.

@asottile
Copy link
Contributor Author

asottile commented Oct 9, 2018

This is pretty special / broken from the setuptools / wheel side. Here's some data:

Checking distribution long/dist/pkg-0.0.0-py3-none-any.whl: 
*******************************************************************************
description: 'long description\n\n\n'
description_content_type: 'text/markdown'
*******************************************************************************

Checking distribution missing/dist/pkg-0.0.0-py3-none-any.whl: 
*******************************************************************************
description: 'UNKNOWN\n\n\n'
description_content_type: None
*******************************************************************************

Checking distribution missing_long/dist/pkg-0.0.0-py3-none-any.whl: 
*******************************************************************************
description: 'UNKNOWN\n\n\n'
description_content_type: 'text/markdown'
*******************************************************************************

Checking distribution missing_type/dist/pkg-0.0.0-py3-none-any.whl: 
*******************************************************************************
description: 'long description\n\n\n'
description_content_type: None
*******************************************************************************

Checking distribution long/dist/pkg-0.0.0.tar.gz: 
*******************************************************************************
description: 'long description'
description_content_type: 'text/markdown'
*******************************************************************************

Checking distribution missing/dist/pkg-0.0.0.tar.gz: 
*******************************************************************************
description: None
description_content_type: None
*******************************************************************************

Checking distribution missing_long/dist/pkg-0.0.0.tar.gz: 
*******************************************************************************
description: None
description_content_type: 'text/markdown'
*******************************************************************************

Checking distribution missing_type/dist/pkg-0.0.0.tar.gz: 
*******************************************************************************
description: 'long description'
description_content_type: None
*******************************************************************************

Things to note here:

  • wheel will set the description to 'UNKNOWN\n\n\n' when it is missing
  • wheel seems to always add \n\n\n to both the description and content type
  • these fields appear to always be present, but are sometimes None

@asottile
Copy link
Contributor Author

asottile commented Oct 9, 2018

Here's the new behaviour:

$ twine check $(find */dist/* -type f | sort)
Checking distribution long/dist/pkg-0.0.0-py3-none-any.whl: Passed
Checking distribution missing/dist/pkg-0.0.0-py3-none-any.whl: warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.
warning: `long_description` missing.
Passed
Checking distribution missing_long/dist/pkg-0.0.0-py3-none-any.whl: warning: `long_description` missing.
Passed
Checking distribution missing_type/dist/pkg-0.0.0-py3-none-any.whl: warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.
Passed
Checking distribution long/dist/pkg-0.0.0.tar.gz: Passed
Checking distribution missing/dist/pkg-0.0.0.tar.gz: warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.
warning: `long_description` missing.
Passed
Checking distribution missing_long/dist/pkg-0.0.0.tar.gz: warning: `long_description` missing.
Passed
Checking distribution missing_type/dist/pkg-0.0.0.tar.gz: warning: `long_description_content_type` missing.  defaulting to `text/x-rst`.
Passed

@asottile
Copy link
Contributor Author

@sigmavirus24 want to take another pass at this?

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.

4 participants