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

Prioritizing source directory in the sys.path #384

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

peekxc
Copy link
Contributor

@peekxc peekxc commented Nov 13, 2024

This PR prioritizes the supplied source directory in the sys.path.

Currently, the source directory of the Builder instance, when supplied, is appended to sys.path:

def build(self, filter: str = "*"):
    ...
    if self.source_dir:
	import sys
        sys.path.append(self.source_dir)

I think the source directory should come first:

def build(self, filter: str = "*"):
    ...
    if self.source_dir:
	import sys
        if sys.path[0] != self.source_dir:
            sys.path.insert(0, self.source_dir)

By inserting itself into the first position in the path, module imports from the given source directory are prioritized over other modules. In particular, if one has a source file that happens to share the same name with another file also in the path (e.g. random, trace, collections, etc.), this change ensures quartodoc/griffe picks the package-level module over a base module.

For me, this fixes griffe-related resolution issues that arise from mixing relative imports with editable installs (#323).

@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.68%. Comparing base (ee4fa3c) to head (d209710).

Files with missing lines Patch % Lines
quartodoc/autosummary.py 0.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #384      +/-   ##
==========================================
- Coverage   88.78%   88.68%   -0.10%     
==========================================
  Files          37       37              
  Lines        3004     3005       +1     
==========================================
- Hits         2667     2665       -2     
- Misses        337      340       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

2 participants