-
Notifications
You must be signed in to change notification settings - Fork 1
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
Handle version specifiers #190
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Split up utils.py into a separate "utils" module.
Depending on each dependency's set of specifiers, a list of on-the-fly ignore rules are created and added to the otherwise user-provided ignore rules. This is a way of using the existing implementation of "ignore rules" to more intelligently suggest an updated set of version specifiers for a dependency based on the latest version retrieved from 'pip index versions'.
- Instead of completely skipping when URL or non-versioned dependency is found, we "regenerate" the dependency in order to ensure consistent formatting. - Properly continue on from current dependency when it is found that the latest version is already used in the pyproject.toml file. - Don't fail if a current version cannot be found based on '==', '>=', or '~=' operators. Instead use '0.0.0'. - Always replace "-quotations with '-quotations for the updated dependency line when updating the pyproject.toml file.
Only not-equal operator (!=) is relevant. Also, update tests folder API to reflect the updated Python API, including the moved utility functions. Update tests to better reflect edge cases.
The old functionality is kept in to be re-implemented for other frameworks and/or choose it in a future toggle option.
Instead of through 'pip._vendor.packaging'. Add as core dependency.
Only having a single python_version marker is supported, furthermore, having any other markers are not respected by this implementation.
Instead of having this logic embedded in 'get_min_max_py_version()'.
Codecov Report
@@ Coverage Diff @@
## main #190 +/- ##
==========================================
+ Coverage 72.09% 79.95% +7.85%
==========================================
Files 9 12 +3
Lines 577 828 +251
==========================================
+ Hits 416 662 +246
- Misses 161 166 +5
|
This is only relevant if no specifiers are given.
Replace all ignored warnings with "error" to make all warnings errors.
Test pre_commit input.
This is validated only when the `ci-cd` package is installed and used, and is validated against the Python versions it supports.
Add pyupgrade as a pre-commit hook with --py37-plus arg. Run and upgrade all files accordingly. Configure mypy to check typing expecting Python 3.7.
This reverts commit b6578a8.
This reverts commit d161a2f.
This reverts commit 1b561ef.
This reverts commit 5ba668b.
Check that e.g. using the unsupported '===' operator raises an exception as expected.
daniel-sintef
approved these changes
Nov 9, 2023
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.
It looks OK, I think we should keep reviews under 375 LOC per 45 minute session https://smartbear.com/learn/code-review/best-practices-for-peer-code-review/
This was referenced Nov 10, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #141
This is a different approach to fixing #141 from #181, in that instead of creating a whole new class (
SemanticVersionRange
) to define the version range specified by the version specifier set of a dependency, it utilizes thepackaging
package to parse the version specifier set and generate "ignore" rules to utilize the existing logic for handling "ignore" rules.In this way, it's more of a "minimum implementation" and should be easier and more straight forward. However, what may really be happening, is simply just making the reading and understanding of the "ignore" rules implementation the point at which one may struggle to understand the implementation.
But again, since this logic already exists, this does not add additional complexity (which cannot be said of the solution presented in #181).
In addition to parsing the dependency-specific version specifier set as "ignore" rules, support for the
python_version
marker is also implemented, although be it in a limited capacity - mainly due to not over-complicating the logic further.Also, the
utils.py
file has been split up into it's separate parts and moved into dedicated files under a newutils
folder - effectively changing theci-cd
package's Python API.Finally, some formatting options have been added when printing to the console. These options include colorization and general formatting (bold, italic, etc.). Note, these are only displayed in any given terminal if the terminal supports it.
These options have only been implemented for the
update-deps
task, since this is the only one being touched properly by this PR.Note, the Python API changes mentioned above has also resulted in a change in the test file structure.
Because all utility functions previously found in
ci_cd.tasks.update_deps
have been moved to the newci_cd.utils.versions
module, some tests have also been moved file, accordingly.Further suggested improvements for future PRs can include:
packaging
package.Things to do prior to this PR being ready for review: