Skip to content

Conversation

@Katze719
Copy link

@Katze719 Katze719 commented Mar 10, 2025

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.

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 10, 2025

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]
  }
Loading

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

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 @Katze719 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a unit test for the _get_ignored_files method to ensure it behaves as expected with different combinations of vcs ignored files, explicitly excluded files, and explicitly included files.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

Comment on lines 95 to 104
def _get_ignored_files(self, vcs_ignored_files, explicitly_excluded, explicitly_included):
"""
Returns the set of ignored files based on:
- vcs_ignored_files: files or directories ignored by the version control system,
- explicitly_excluded: files explicitly marked for exclusion,
- explicitly_included: files or directories explicitly marked for inclusion.
If a directory is explicitly included, all files and subdirectories within it
will not be ignored even if they appear in vcs_ignored_files.
"""
Copy link

Choose a reason for hiding this comment

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

question: Review path resolution consistency when comparing paths.

The method resolves each candidate and the explicitly included paths using Path.resolve(strict=False). Please ensure that all these paths are in a consistent format (e.g., all absolute) and relative context is correctly accounted for, especially since explicitly included files are added relative to self._path in find_excluded_files. This consistency is critical to avoid mismatches in path comparisons.

@Katze719 Katze719 changed the title fix: 🐛 do not exclude files in exlplicitly included directorys fix: 🐛 do not exclude files in explicitly included directorys Mar 10, 2025
@Katze719
Copy link
Author

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

do what ever you want with this code

@Katze719
Copy link
Author

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

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.

poetry build does not include files unter tools.poetry.include when they are in the .gitignore

1 participant