Skip to content

Commit

Permalink
Merge pull request #1246: Configure Pyright
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlin authored May 22, 2024
2 parents c241569 + e5ced1c commit 1694a3f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
12 changes: 11 additions & 1 deletion docs/contribute/DEV_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,19 @@ During development you can run static type checks using [mypy][]:
$ mypy
# No output is good!

There are also many [editor integrations for mypy][].
and [pyright][]:

$ npx pyright
...
Found 40 source files
0 errors, 0 warnings, 0 infos
Completed in 2sec

There are also many [editor integrations for mypy][], and Pyright can be
[configured for VS Code][].

[editor integrations for mypy]: https://github.com/python/mypy#integrations
[configured for VS Code]: https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance#settings-and-customization

### Removing features

Expand Down
30 changes: 30 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"pythonVersion": "3.8",
"include": ["augur/"],


// These are rules that are enabled by default and currently have violations.

// TODO: go through these exceptions and determine if they should be kept or
// removed and violations addressed.

// TODO: consider aligning this with the same file in nextstrain/cli:
// <https://github.com/nextstrain/cli/blob/-/pyrightconfig.json>
"reportArgumentType": false,
"reportAttributeAccessIssue": false,
"reportCallIssue": false,
"reportGeneralTypeIssues": false,
"reportIncompatibleMethodOverride": false,
"reportMissingImports": false,
"reportMissingModuleSource": false,
"reportOperatorIssue": false,
"reportOptionalIterable": false,
"reportOptionalMemberAccess": false,
"reportOptionalOperand": false,
"reportOptionalSubscript": false,
"reportPossiblyUnboundVariable": false,
"reportPrivateImportUsage": false,
"reportSelfClsParameterName": false,
"reportUndefinedVariable": false,
"reportUnusedExpression": false,
}
22 changes: 22 additions & 0 deletions tests/test_pyright.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
from pathlib import Path
from shutil import which
from subprocess import run

topdir = Path(__file__).resolve().parent.parent

pyright = which("pyright")
npx = which("npx")

if pyright:
pyright = [pyright]
elif npx:
pyright = [npx, "pyright"]
else:
pyright = None

@pytest.mark.skipif(not pyright, reason = "pyright is not available")
def test_pyright():
# Check the exit status ourselves for nicer test output on failure
result = run(pyright, cwd = topdir)
assert result.returncode == 0, "pyright exited with errors"

0 comments on commit 1694a3f

Please sign in to comment.