poetry-core icon indicating copy to clipboard operation
poetry-core copied to clipboard

fix: :bug: do not exclude files in explicitly included directorys

Open Katze719 opened this issue 11 months ago • 3 comments

Resolves: python-poetry#10259

  • [ ] Added tests for changed code.
  • [ ] Updated documentation for changed code.

Summary by Sourcery

Bug Fixes:

  • Ensures that files within explicitly included directories are not ignored during the build process.

Katze719 avatar Mar 10 '25 06:03 Katze719

Reviewer's Guide by Sourcery

This pull request introduces a new method, _get_ignored_files, to accurately determine ignored files during the build process. It considers VCS ignores, explicit excludes, and, most importantly, explicit includes, ensuring that files within explicitly included directories are not inadvertently excluded. The find_excluded_files method is refactored to leverage this new method, improving the accuracy of file exclusion during the build process.

Updated class diagram for Builder

classDiagram
  class Builder {
    -_path: Path
    -_poetry: Poetry
    -_env: Env
    -_excluded_files: set[str] | None
    -_package: Package
    +build(target_dir: Path | None) : Path
    +find_excluded_files(fmt: str | None = None) : set[str]
    -_apply_local_version_label() : None
    -_get_ignored_files(vcs_ignored_files, explicitly_excluded, explicitly_included) : set[str]
  }

File-Level Changes

Change Details Files
Introduces a new method to determine ignored files, taking into account VCS ignores, explicit excludes, and explicit includes.
  • Added _get_ignored_files method to handle the logic for determining ignored files based on VCS ignores, explicit excludes, and explicit includes.
  • The _get_ignored_files method ensures that if a directory is explicitly included, all files and subdirectories within it will not be ignored, even if they appear in VCS ignored files.
  • The is_explicitly_included method checks if a given path is explicitly included by comparing it to the explicitly included paths and their subpaths.
src/poetry/core/masonry/builders/builder.py
Refactors the find_excluded_files method to use the new _get_ignored_files method.
  • Replaced the previous logic for calculating ignored files with a call to the _get_ignored_files method.
  • The find_excluded_files method now uses the _get_ignored_files method to determine the set of ignored files.
src/poetry/core/masonry/builders/builder.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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on an issue to generate a plan of action for it.

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

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Mar 10 '25 06:03 sourcery-ai[bot]

NVM using poetry_test_issue_10259/myLibs/**/* works 🙃🙃🙃

do what ever you want with this code

Katze719 avatar Mar 10 '25 07:03 Katze719

maybe, could we add to the documentation that globing is supported for including/excluding files within the pyproject.toml?

Katze719 avatar Mar 10 '25 07:03 Katze719