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

fix(factory): safe get extras in scripts and config #404

Merged
merged 1 commit into from
Jun 26, 2022

Conversation

mkniewallner
Copy link
Member

Resolves: python-poetry/poetry#4665

  • Added tests for changed code.
  • Updated documentation for changed code. Not applicable

According to:

"required": [
"name",
"version",
"description"
],

"required": [
"reference",
"type"
]

  • extras is not required in the main config (under poetry.tools.extras)
  • extras is not required when defining a script (under poetry.tools.scripts) using the syntax introduced in Added script file feature #40

Despite that, Factory.validate assumes that extras key is always present for both cases by hard accessing it, making the script definition fail for 2 possible reasons:

  • poetry.tool.extras is not defined at all
  • a script defined as a dict doesn't define an extras key

This PR fixes those 2 use cases by soft accessing the key and defaulting to an empty list/dict.
It also adds tests to validate the errors/warnings that could happen when using the strict flag, since it was lacking some coverage.

@mkniewallner
Copy link
Member Author

mkniewallner commented Jun 24, 2022

The tests that is failing does not seem related to the changes in the PR.
I can also reproduce locally and on main branch, and only on Python 3.7, same as the CI.

TBBle
TBBle previously approved these changes Jun 24, 2022
@sonarcloud
Copy link

sonarcloud bot commented Jun 25, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@mkniewallner mkniewallner marked this pull request as ready for review June 25, 2022 13:05
@mkniewallner
Copy link
Member Author

Rebased from main to pick up #406 so that tests can pass.

@neersighted neersighted merged commit f6e8b58 into python-poetry:main Jun 26, 2022
@mkniewallner mkniewallner deleted the fix-scripts-extras branch July 9, 2022 12:02
@radoering radoering mentioned this pull request Jul 12, 2022
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.

'Key "extras" does not exist.'
3 participants