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

Extend exclude option #4461

Closed
Gobot1234 opened this issue Jan 15, 2023 · 5 comments
Closed

Extend exclude option #4461

Gobot1234 opened this issue Jan 15, 2023 · 5 comments
Labels
as designed Not a bug, working as intended enhancement request New feature or request

Comments

@Gobot1234
Copy link

Is your feature request related to a problem? Please describe.
An option to extend the default excluded paths would be really useful as you can just add a couple of untyped or hard to type files to the default list of exclude.

Describe the solution you'd like
A config file option which adds support for extending the default exclude value to simply add extras to the default exclude.

Additional context
Other programs like black and isort both support this flag

@Gobot1234 Gobot1234 added the enhancement request New feature or request label Jan 15, 2023
@erictraut
Copy link
Collaborator

Pyright already exports an "exclude" configuration option.

@erictraut erictraut added the as designed Not a bug, working as intended label Jan 15, 2023
@Gobot1234
Copy link
Author

This isn't about just exclude, this is about being able to add values to that exclude without having to either know or copy them out see psf/black#2005

@erictraut
Copy link
Collaborator

The list of default excludes for pyright is short, and they are sufficient for nearly all users. The explicit exclude configuration setting is an advanced option. If you have need to explicitly exclude something, it does not seem onerous to add one or two more items to the explicit exclude list if necessary. I don't think this is worth adding yet another configuration option that needs to be managed and composed with existing configuration options.

@blakeNaccarato
Copy link
Contributor

blakeNaccarato commented Jan 25, 2024

Example of proper exclude override

I hope it's okay to drop in here to collate some references to help clarify exactly how to override exclude, because the portion in the docs for exclude (the second option down), does confuse things just a little bit (regarding virtual environments).

In short, exclude e.g. ...<custom exclude>... as follows:

exclude = ["**/node_modules", "**/__pycache__", "**/.*", "...<custom exclude>..."]

Proposed documentation change

I could open a separate issue to track this, or if it looks good, I can just open a PR to do it, or leave it to the team to roll into some other change. Reword the possibly misleading line (original line and reasoning below) to say (edit is emphasized):

If no exclude paths are specified, Pyright automatically excludes the following: **/node_modules, **/__pycache__, **/.*. Pyright also separately handles exclusion of virtual environment directories. For more details, refer to the import resolution documentation.

(link broken here because it's a local link that would render properly if merged into the document)

Reasoning

The confusion arises from the following line:

If no exclude paths are specified, Pyright automatically excludes the following: **/node_modules, **/__pycache__, **/.* and any virtual environment directories.

This wording could give the reader the false belief that exclude handles virtual environment exclusion (magically somehow), and therefore we should make sure to add e.g. venv to exclude when we override it. The source suggests that exclude doesn't handle any virtual environment-related exclusion:

const defaultExcludes = ['**/node_modules', '**/__pycache__', '**/.*'];

and configuring your Python environment docs and venv related docs (eighth and ninth options down), seems to mostly reassure us of that.

Anyways, I just happened upon this confusion when trying to troubleshoot some Pylance slowdowns, and wasn't 100% sure that Pylance was skipping my virtual environment directory.

@erictraut
Copy link
Collaborator

Yeah, if you'd like to submit a PR, that'd be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
as designed Not a bug, working as intended enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants