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

78 permanent errors in builtins.pyi #6409

Open
tylerlaprade opened this issue Sep 18, 2024 · 6 comments
Open

78 permanent errors in builtins.pyi #6409

tylerlaprade opened this issue Sep 18, 2024 · 6 comments
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@tylerlaprade
Copy link

Environment data

  • Pylance version: v2024.9.100 (pre-release) or v2024.14.1 (occurs with both)
  • OS and version: MacOS Sonoma 14.6.1
  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.2

Code Snippet

pyrightconfig.json

{
	"pythonVersion": "3.12",
	"include": ["hanaq"],
	"extraPaths": ["hanaq"],
	"ignore": [
		"**/node_modules",
		"**/__pycache__",
		"**/.*",
		"**/dist",
		"**/.vscode",
		"**/*.pyi",
		"**/__init__.py"
	],
	"exclude": ["hanaq/abacus/migrations"],
	"typeCheckingMode": "standard",
	"enableTypeIgnoreComments": false,
	"strictListInference": true,
	"strictSetInference": true,
}

Expected behavior

No errors from outside my code

Actual behavior

image
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Sep 18, 2024
@erictraut
Copy link
Contributor

Yes, these are real type errors in builtins.pyi, so pyright is correct in generating these diagnostics.

Typeshed maintainers are forced to use incompatible method overrides because the stdlib does not always honor the Liskov Substitution Principle. The typeshed CI pipelines explicitly disable a number of pyright's checks including reportIncompatibleMethodOverride and reportPrivateUsage. If you would prefer that these errors be suppressed, you could submit a bug report or a PR to the typeshed project to add # pyright: ignore comments.

@tylerlaprade
Copy link
Author

Hi @erictraut,

As per Jelle's response, those errors should not be showing up. Is there a way I can configure pyright to not show them? I tried various ways of adding the file to my ignore array, but nothing seemed to work.

Regards,
Tyler

@erictraut
Copy link
Contributor

Jelle is correct that if you run the pyright CLI tool on your project, you should not see errors in stub files or library files that are imported but are not themselves part of your project. Likewise, if you are using the pyright language server (or pylance) and open files that are part of your project, you won't see errors from builtins.pyi even though every source file implicitly imports from the builtins.pyi module.

However, if you explicitly open builtins.pyi (which isn't part of your project) within your editor, the language server will invoke pyright on that file using default pyright settings. I'm guessing that's what's happening here. Are you opening builtins.pyi when working on your project? If so, you will see errors in this file appear within the "problems" panel while this file is open. If you then close the file, these errors will disappear from the problems panel. This behavior isn't specific to builtins.pyi. It occurs for any ".py" or ".pyi" file that you open in your editor if that file isn't part of your project.

@tylerlaprade
Copy link
Author

Ah, I see where the confusion is. I am not opening builtins.pyi and wouldn't even know it exists if it wasn't for these persistent errors. Even with no files open at all, Pylance has been showing these 78 errors at all times since a few weeks ago. They make it hard for me to focus on actual errors that might arise since my Problems pane is full at all times.

@erictraut
Copy link
Contributor

Ah, interesting. If you're seeing these all the time even when builtins.pyi isn't open, then pylance apparently thinks that builtins.pyi is part of your project. That points to a configuration issue. I'll let the pylance team help diagnose that issue with you.

@tylerlaprade
Copy link
Author

Thanks Eric!
@StellaHuang95, could this ticket be reopened, please?

@debonte debonte added needs repro Issue has not been reproduced yet and removed by design labels Sep 22, 2024
@debonte debonte reopened this Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

4 participants