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(dependency): do not discard unknown urls #817

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

abn
Copy link
Member

@abn abn commented Jan 17, 2025

Prior to this change, when parsing PEP 508 requirement strings, the Dependency class silently discarded any URI tokens that cannot be validated as existing files.

Resolves: python-poetry/poetry#10068

This requires python-poetry/poetry#10069 to be merged to for downstream CI jobs to pass.

Summary by Sourcery

Bug Fixes:

  • Fixed an issue where invalid URI tokens in PEP 508 requirement strings were silently discarded.

@abn abn requested a review from a team January 17, 2025 19:06
Copy link

sourcery-ai bot commented Jan 17, 2025

Reviewer's Guide by Sourcery

This pull request modifies the Dependency class to no longer discard unknown URLs when parsing PEP 508 requirement strings. Instead, it attempts to infer the dependency type based on the path suffix, allowing for downstream error handling.

Class diagram for dependency handling changes

classDiagram
    class Dependency {
        +_make_file_or_dir_dep(name, path, base, subdirectory, extras)
    }
    class FileDependency {
        +name: str
        +path: Path
        +base: str
        +directory: str
        +extras: list
    }
    class DirectoryDependency {
        +name: str
        +path: Path
        +base: str
        +extras: list
    }
    Dependency ..> FileDependency : creates
    Dependency ..> DirectoryDependency : creates
    note for Dependency "Modified to handle non-existent paths"
Loading

File-Level Changes

Change Details Files
Modified the _make_file_or_dir_dep method to infer dependency type based on path suffix.
  • The method now checks if a path is a file (if it exists) or relies on the suffix to guess the dependency type.
  • If the path has a suffix, it is treated as a file dependency.
  • If the path does not have a suffix, it is treated as a directory dependency.
src/poetry/core/packages/dependency.py
Added a test case for handling invalid path requirements.
  • Added a new test case test_to_pep_508_with_invalid_path_requirement to verify that dependencies with invalid paths are correctly parsed.
  • The test case checks if the dependency type is correctly inferred based on the path suffix.
tests/packages/test_dependency.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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

@abn abn force-pushed the issues/10069 branch 3 times, most recently from df4cba1 to b8ad05b Compare January 17, 2025 19:34
@abn abn marked this pull request as ready for review January 18, 2025 01:18
@abn abn enabled auto-merge (rebase) January 18, 2025 01:18
Prior to this change, when parsing PEP 508 requirement strings,
the `Dependency` class silently discarded any URI tokens that cannot
be validated as existing files.

Resolves: python-poetry/poetry#10068
@abn abn merged commit bb5c750 into python-poetry:main Jan 18, 2025
18 checks passed
@abn abn deleted the issues/10069 branch January 18, 2025 23:19
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.

Malformed "@" dependencies in project.dependencies get silently ignored
2 participants