-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Initial pyright config #4192
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
Initial pyright config #4192
Changes from 14 commits
5259c21
c4f5c25
1727564
98951f8
6481724
c3c5d64
296f9e8
a7ea1cb
3399be9
92161eb
5fb0c4f
69c16a2
c47a46c
5cd06e0
11230b1
62b9cbd
e2a6f4a
f8faa45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Split workflow file to not interfere with skeleton | ||
name: pyright | ||
|
||
on: | ||
merge_group: | ||
push: | ||
branches-ignore: | ||
# temporary GH branches relating to merge queues (jaraco/skeleton#93) | ||
- gh-readonly-queue/** | ||
tags: | ||
# required if branches-ignore is supplied (jaraco/skeleton#103) | ||
- '**' | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: >- | ||
${{ github.workflow }}- | ||
${{ github.ref_type }}- | ||
${{ github.event.pull_request.number || github.sha }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
# pin pyright so a new version doesn't suddenly cause the CI to fail, | ||
# until types-setuptools is removed from typeshed. | ||
# For help with static-typing issues, or pyright update, ping @Avasam | ||
PYRIGHT_VERSION: "latest" | ||
|
||
# Environment variable to support color support (jaraco/skeleton#66) | ||
FORCE_COLOR: 1 | ||
|
||
# Suppress noisy pip warnings | ||
PIP_DISABLE_PIP_VERSION_CHECK: 'true' | ||
PIP_NO_PYTHON_VERSION_WARNING: 'true' | ||
PIP_NO_WARN_SCRIPT_LOCATION: 'true' | ||
|
||
jobs: | ||
pyright: | ||
strategy: | ||
# https://blog.jaraco.com/efficient-use-of-ci-resources/ | ||
matrix: | ||
python: | ||
- "3.8" | ||
- "3.12" | ||
platform: | ||
- ubuntu-latest | ||
- macos-latest | ||
- windows-latest | ||
include: | ||
- python: "3.9" | ||
platform: ubuntu-latest | ||
- python: "3.10" | ||
platform: ubuntu-latest | ||
- python: "3.11" | ||
platform: ubuntu-latest | ||
# Python 3.8, 3.9 are on macos-13 but not macos-latest (macos-14-arm64) | ||
# https://github.com/actions/setup-python/issues/850 | ||
# https://github.com/actions/setup-python/issues/696#issuecomment-1637587760 | ||
- {python: "3.8", platform: "macos-13"} | ||
exclude: | ||
- {python: "3.8", platform: "macos-latest"} | ||
runs-on: ${{ matrix.platform }} | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
allow-prereleases: true | ||
- name: Install typed dependencies | ||
run: python -m pip install -e .[core,type] | ||
- name: Inform how to run locally | ||
run: | | ||
echo 'To run this test locally with npm pre-installed, run:' | ||
echo '> npx -y pyright@${{ env.PYRIGHT_VERSION }} --threads' | ||
echo 'You can also instead install "Pyright for Python" which will install npm for you:' | ||
if [ '$PYRIGHT_VERSION' == 'latest' ]; then | ||
echo '> pip install -U' | ||
else | ||
echo '> pip install pyright==${{ env.PYRIGHT_VERSION }}' | ||
fi | ||
echo 'pyright --threads' | ||
shell: bash | ||
- name: Run pyright | ||
uses: jakebailey/pyright-action@v2 | ||
with: | ||
version: ${{ env.PYRIGHT_VERSION }} | ||
extra-args: --threads |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/microsoft/pyright/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json", | ||
"exclude": [ | ||
"build", | ||
".tox", | ||
".eggs", | ||
"**/_vendor", // Vendored | ||
"setuptools/_distutils", // Vendored | ||
"setuptools/config/_validate_pyproject/**", // Auto-generated | ||
], | ||
// Our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually. | ||
// "pythonVersion": "3.8", | ||
// For now we don't mind if mypy's `type: ignore` comments accidentally suppresses pyright issues | ||
"enableTypeIgnoreComments": true, | ||
"typeCheckingMode": "basic", | ||
// Too many issues caused by dynamic patching, still worth fixing when we can | ||
"reportAttributeAccessIssue": "warning", | ||
// Fails on Python 3.12 due to missing distutils and on cygwin CI tests | ||
"reportAssignmentType": "warning", | ||
"reportMissingImports": "warning", | ||
"reportOptionalCall": "warning", | ||
// FIXME: A handful of reportOperatorIssue spread throughout the codebase | ||
"reportOperatorIssue": "warning", | ||
// Deferred initialization (initialize_options/finalize_options) causes many "potentially None" issues | ||
// TODO: Fix with type-guards or by changing how it's initialized | ||
"reportArgumentType": "warning", // A lot of these are caused by jaraco.path.build's spec argument not being a Mapping https://github.com/jaraco/jaraco.path/pull/3 | ||
Avasam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"reportCallIssue": "warning", | ||
"reportGeneralTypeIssues": "warning", | ||
"reportOptionalIterable": "warning", | ||
"reportOptionalMemberAccess": "warning", | ||
"reportOptionalOperand": "warning", | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,12 +87,15 @@ def finalize_options(self): | |
|
||
def initialize_options(self): | ||
"""(Required by the original :class:`setuptools.Command` interface)""" | ||
... | ||
|
||
def finalize_options(self): | ||
"""(Required by the original :class:`setuptools.Command` interface)""" | ||
... | ||
|
||
def run(self): | ||
"""(Required by the original :class:`setuptools.Command` interface)""" | ||
... | ||
|
||
def get_source_files(self) -> list[str]: | ||
""" | ||
|
@@ -104,6 +107,7 @@ def get_source_files(self) -> list[str]: | |
with all the files necessary to build the distribution. | ||
All files should be strings relative to the project root directory. | ||
""" | ||
... | ||
|
||
def get_outputs(self) -> list[str]: | ||
""" | ||
|
@@ -117,6 +121,7 @@ def get_outputs(self) -> list[str]: | |
in ``get_output_mapping()`` plus files that are generated during the build | ||
and don't correspond to any source file already present in the project. | ||
""" | ||
... | ||
|
||
def get_output_mapping(self) -> dict[str, str]: | ||
""" | ||
|
@@ -127,3 +132,4 @@ def get_output_mapping(self) -> dict[str, str]: | |
Destination files should be strings in the form of | ||
``"{build_lib}/destination/file/path"``. | ||
""" | ||
... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refer to microsoft/pyright#6487 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python should not require ellipsis when the docstring is provided. I am not 100% inline with the comment of the pyright maintainer... The reason why the linters don't complain about it, is because there is nothing wrong 😅 Does mypy also complains about it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see the problem here is because we are talking specifically about prototypes, and the spec says:
That is a bit disappointing... These pesky ellipsis can be annoying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Further discussion: astral-sh/ruff#8756 (comment) . It does seem to be more accurate to spec. Ruff was also updated to not strip ellipses in Protocols in https://github.com/astral-sh/ruff/releases/tag/v0.1.6 |
Uh oh!
There was an error while loading. Please reload this page.