fix reduce_by_python_constraint for marker unions#846
Conversation
Reviewer's Guide by SourceryThis pull request fixes an issue in Updated class diagram for MarkerclassDiagram
class Marker {
+reduce_by_python_constraint(python_constraint: Constraint) Marker
}
Marker : Implements marker reduction logic
note for Marker "Fixes an issue in `reduce_by_python_constraint` where marker unions were not correctly reduced when the Python constraint allowed all Python versions specified in the union."
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @radoering - I've reviewed your changes - here's some feedback:
Overall Comments:
- The change in
test_onlyfrom'python_version >= "3.8"', "~3.8", ""to'python_version == "3.8"', "~3.8", ""seems incorrect. - The logic in
reduce_by_python_constraintcould be simplified by returningAnyMarker()earlier ifpython_only_markersis empty.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| ("<empty>", "~3.8", "<empty>"), | ||
| ('sys_platform == "linux"', "~3.8", 'sys_platform == "linux"'), | ||
| ('python_version >= "3.8"', "~3.8", ""), | ||
| ('python_version == "3.8"', "~3.8", ""), |
There was a problem hiding this comment.
I just changed this test because there is a duplicate of the original test some lines below.
| ' or python_version >= "3.9" or sys_platform == "win32"' | ||
| ), | ||
| "~3.7 || ~3.9", | ||
| 'sys_platform == "linux" or sys_platform == "win32"', |
There was a problem hiding this comment.
I removed these test because with the fix they are not that intesting anymore because they are too similar to the test above.
E.g. if the python constraint is `>=3.9`, reducing `python_version >= "3.8" or sys_platform == "linux"` should result in `AnyMarker` (not `sys_platform == "linux"`).
5859f41 to
22edd5c
Compare
E.g. if the python constraint is
>=3.9, reducingpython_version >= "3.8" or sys_platform == "linux"should beAnyMarker(notsys_platform == "linux").Resolves: python-poetry/poetry#10239
Related-to: python-poetry/poetry#10237
Summary by Sourcery
Bug Fixes:
reduce_by_python_constraintwhere marker unions were not correctly reduced when a python constraint was applied, resulting in incorrect marker evaluation.