Skip to content

Conversation

@radoering
Copy link
Member

@radoering radoering commented Aug 20, 2025

Summary by Sourcery

CI:

  • Include Python 3.14 in the CI workflow for testing

Summary by Sourcery

Ensure Python 3.14 compatibility by updating the CI workflow, refining Windows file URI handling with deprecation warnings, adjusting imports for Python version differences, and updating tests and integration scripts accordingly

Bug Fixes:

  • Correct parsing of drive-letter file URLs on Windows by prepending a leading slash and issuing deprecation warnings

Enhancements:

  • Import Traversable from importlib.resources.abc on Python 3.11+ for compatibility
  • Refactor PEP 517 backend test to reference the build-system requirement via URI instead of file path

CI:

  • Add Python 3.14 to the CI test matrix

Tests:

  • Add tests for deprecated Windows file URL patterns
  • Update directory and file dependency tests to include platform-specific leading slashes in file URIs

@sourcery-ai
Copy link

sourcery-ai bot commented Aug 20, 2025

Reviewer's Guide

Adds Python 3.14 to CI, refines file URL parsing with deprecation warnings, standardizes test URL prefixes for Windows, updates PEP 517 backend test to use URIs, and conditionally imports Traversable based on Python version.

Sequence diagram for file URL parsing and warning logic in utils.py

sequenceDiagram
participant "url_to_path()"
participant "re"
participant "warnings"
participant "User"
"url_to_path()"->>"re": match netloc against pattern
alt netloc matches drive letter pattern
    "url_to_path()"->>"warnings": warn about missing slash or drive letter
    "warnings"->>"User": display UserWarning
else netloc is UNC path
    "url_to_path()"->>"netloc": prepend UNC share notation
end
Loading

Class diagram for conditional Traversable import in helpers.py

classDiagram
class helpers {
    +_get_license_file() Traversable
}
class Traversable
helpers --> Traversable: returns
note for helpers "Traversable is imported from importlib.abc for Python <3.11, from importlib.resources.abc for Python >=3.11"
Loading

File-Level Changes

Change Details Files
CI workflow updated to include Python 3.14
  • Added '3.14' to Python test versions in the CI matrix
.github/workflows/tests.yaml
Refine url_to_path logic to warn on deprecated drive-letter URLs
  • Added regex to detect drive-letter netlocs
  • Prepended leading slash and emitted UserWarning for missing slash
  • Fell back to UNC share handling for other netlocs
src/poetry/core/packages/utils/utils.py
Add deprecated URL warning tests for Windows
  • Introduced tests for missing leading slash drive-letter URL
  • Added tests for missing slash after 'localhost' drive-letter URL
  • Applied pytest.mark.skipif for Windows-only tests
tests/packages/utils/test_utils_urls.py
Standardize file:// URL prefix handling in dependency tests
  • Introduced 'prefix' variable to conditionally prefix slash on Windows
  • Updated directory and file dependency tests to use the prefix
tests/packages/test_directory_dependency.py
tests/packages/test_file_dependency.py
Conditionally import Traversable based on Python version
  • Import from importlib.abc when Python < 3.11
  • Import from importlib.resources.abc when Python ≥ 3.11
src/poetry/core/spdx/helpers.py
Use URI instead of file:// path in PEP 517 backend test
  • Replaced file://{project_path} with {project_uri} in build-system template
  • Adjusted test to write URI via .as_uri()
tests/integration/test_pep517_backend.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@radoering radoering force-pushed the python314 branch 2 times, most recently from 7c39afb to 8b97b70 Compare August 22, 2025 17:33
@radoering radoering changed the title run tests with Python 3.14 ensure Python 3.14 compatibility Aug 22, 2025
@radoering radoering force-pushed the python314 branch 2 times, most recently from 7b26d90 to 4be6df2 Compare September 13, 2025 07:28
@radoering radoering marked this pull request as ready for review September 13, 2025 07:28
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `tests/packages/test_directory_dependency.py:99` </location>
<code_context>
     expected = f"demo @ {path.as_uri()}"

-    requirement = f"demo @ file://{path.as_posix()}"
+    prefix = "/" if sys.platform == "win32" else ""
+    requirement = f"demo @ file://{prefix}{path.as_posix()}"
     _test_directory_dependency_pep_508("demo", path, requirement, expected)

</code_context>

<issue_to_address>
Test parametrization could improve readability and reduce duplication.

Consider using pytest parametrization to handle both Windows and non-Windows file URL prefixes, reducing repeated logic across tests.
</issue_to_address>

### Comment 2
<location> `tests/packages/test_file_dependency.py:88` </location>
<code_context>
     expected = f"demo @ {path.as_uri()}"

-    requirement = f"demo @ file://{path.as_posix()}"
+    prefix = "/" if sys.platform == "win32" else ""
+    requirement = f"demo @ file://{prefix}{path.as_posix()}"
     _test_directory_dependency_pep_508("demo", path, requirement, expected)

</code_context>

<issue_to_address>
Consider adding tests for malformed file URLs (e.g., missing slashes, extra slashes, or invalid characters).

Adding tests for malformed or ambiguous file URLs will help verify error handling and improve reliability.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@radoering radoering merged commit 8c38347 into python-poetry:main Sep 13, 2025
22 checks passed
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.

1 participant