Skip to content

Commit

Permalink
basedpyright
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Jan 15, 2024
1 parent ed62a2d commit 2b61f9c
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 153 deletions.
5 changes: 4 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"detachhead.basedpyright",
"ms-python.pylint",
"ms-python.black-formatter",
"ms-python.mypy-type-checker",
Expand All @@ -11,5 +11,8 @@
"tamasfe.even-better-toml",
"redhat.vscode-yaml",
"robocorp.robotframework-lsp"
],
"unwantedRecommendations": [
"ms-python.vscode-pylance",
]
}
12 changes: 0 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
"git.useEditorAsCommitInput": false,
"diffEditor.ignoreTrimWhitespace": false,
"terminal.integrated.persistentSessionReviveProcess": "never",
"mypy-type-checker.args": [
"--ide",
"--python-version",
"3.8"
],
"mypy-type-checker.importStrategy": "fromEnvironment",
"files.autoSave": "onFocusChange",
"search.useIgnoreFiles": true,
"git.useCommitInputAsStashMessage": true,
Expand All @@ -28,9 +22,6 @@
"python.analysis.typeCheckingMode": "off",
"python.analysis.autoFormatStrings": true,
"python.analysis.gotoDefinitionInStringLiteral": true,
"python.analysis.typeshedPaths": [
"./.venv/lib/site-packages/mypy/typeshed"
],
"pylint.importStrategy": "fromEnvironment",
"pylint.severity": {
"convention": "Warning",
Expand All @@ -56,8 +47,5 @@
"search.exclude": {
"pw": true
},
"mypy-type-checker.ignorePatterns": [
"pw"
],
"python.terminal.activateEnvInCurrentTerminal": true
}
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"problemMatcher": []
},
{
"label": "basedmypy - all files",
"label": "basedpyright - all files",
"type": "shell",
"command": "./pw",
"args": ["pdm", "run", "mypy_all"],
"args": ["run", "basedpyright"],
"presentation": {
"clear": true
},
Expand Down
60 changes: 23 additions & 37 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 64 additions & 34 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test = "pdm run pytest -n auto"
[tool.pdm.dev-dependencies]
lint = [
"black>=23",
"basedmypy>=2.1",
"basedpyright @ git+https://github.com/detachhead/basedpyright.git@d0b3dbe33add247adf58b2b24f30953cf15d97e3",
"pylint>=3.0.0a7",
"ruff>=0.0.290",
"robotframework-robocop>=4.1.0",
Expand All @@ -44,12 +44,6 @@ lint = [
test = ["lxml>=4.9.3", "lxml-stubs>=0.4.0", "pytest-xdist>=3.5.0"]
docs = ["pdoc>=14.1.0"]

# maybe these should be pyprojectx scripts instead once https://github.com/pyprojectx/pyprojectx/issues/26 is fixed
[tool.pdm.scripts]
_mypy_package = { cmd = "pdm run mypy -p pytest_robotframework" }
_mypy_tests = { cmd = "pdm run mypy -p tests" }
mypy_all = { composite = ["_mypy_package", "_mypy_tests"] }

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
Expand Down Expand Up @@ -268,36 +262,73 @@ addopts = ['-p no:robotframework', '--ignore=tests/fixtures']
xfail_strict = true
enable_assertion_pass_hook = true

[tool.mypy]
allow_redefinition = false
enable_error_code = "helpful-string"
default_return = false # enabled for our own code only as 3rd party code is not coompatible
cache_dir = 'nul' # disable cache because it sucks

[[tool.mypy.overrides]]
module = ['pytest_robotframework.*', 'tests.*']
default_return = true

[[tool.mypy.overrides]]
module = ['robot.*']
no_implicit_reexport = false
ignore_missing_py_typed = true # https://github.com/robotframework/robotframework/issues/4822

[[tool.mypy.overrides]]
module = ['deepmerge.*']
ignore_missing_py_typed = true


[tool.pyright]
# we dont use pyright for type checking, this is just for vscode import suggestions and reachability checks
pythonVersion = "3.8"
pythonPlatform = "All"
typeCheckingMode = "strict"
reportMissingTypeStubs = false
strictListInference = true
strictDictionaryInference = true
strictSetInference = true
deprecateTypingAliases = true
enableExperimentalFeatures = true
disableBytesTypePromotions = true
reportPropertyTypeMismatch = true
reportFunctionMemberAccess = true
reportMissingModuleSource = true
reportImportCycles = true
reportUnusedClass = true
reportUnusedFunction = true
reportUnusedVariable = true
reportDuplicateImport = true
reportWildcardImportFromLibrary = true
reportUntypedFunctionDecorator = true
reportUntypedClassDecorator = true
reportUntypedBaseClass = true
reportUntypedNamedTuple = true
reportPrivateUsage = true
reportTypeCommentUsage = true
reportConstantRedefinition = true
reportDeprecated = true
reportIncompatibleMethodOverride = true
reportIncompatibleVariableOverride = true
reportInconsistentConstructor = true
reportOverlappingOverload = true
reportMissingSuperCall = true
reportUninitializedInstanceVariable = true
reportInvalidStringEscapeSequence = true
reportUnknownParameterType = true
reportUnknownArgumentType = true
reportUnknownLambdaType = true
reportUnknownVariableType = true
reportUnknownMemberType = true
reportMissingParameterType = true
reportMissingTypeArgument = true
reportInvalidTypeVarUse = true
reportCallInDefaultInitializer = true
reportUnnecessaryIsInstance = true
reportUnnecessaryCast = true
reportUnnecessaryComparison = true
reportUnnecessaryContains = true
reportAssertAlwaysTrue = true
reportSelfClsParameterName = true
reportImplicitStringConcatenation = false # conflicts with black
reportInvalidStubStatement = true
reportIncompleteStub = true
reportUnsupportedDunderAll = true
reportUnusedCallResult = true
reportUnusedCoroutine = true
reportUnusedExpression = true
reportUnnecessaryTypeIgnoreComment = true
reportMatchNotExhaustive = true
reportImplicitOverride = true
reportShadowedImports = true

[tool.ruff]
unsafe-fixes = true
extend-select = ["ALL"]
ignore = [
"ANN", # flake8-annotations (covered by mypy)
"ANN", # flake8-annotations (covered by pyright)
"COM", # flake8-commas (covered by black)
"EM", # flake8-errmsg
"FIX", # flake8-fixme
Expand All @@ -307,13 +338,13 @@ ignore = [
"PLR2004", # Magic value used in comparison
"PLR1722", # Use `sys.exit()` instead of `exit`
"PLW2901", # `for` loop variable overwritten by assignment target
"PLE0605", # Invalid format for `__all__`, must be `tuple` or `list` (covered by mypy)
"PLE0605", # Invalid format for `__all__`, must be `tuple` or `list` (covered by pyright)
"PLR0911", # Too many return statements
"PLW0603", # Using the global statement is discouraged
"PLC0105", # `TypeVar` name does not reflect its covariance
"PLC0414", # Import alias does not rename original package (used by mypy for explicit re-export)
"RUF013", # PEP 484 prohibits implicit Optional (covered by mypy)
"RUF016", # Slice in indexed access to type (covered by mypy)
"PLC0414", # Import alias does not rename original package (used by pyright for explicit re-export)
"RUF013", # PEP 484 prohibits implicit Optional (covered by pyright)
"RUF016", # Slice in indexed access to type (covered by pyright)
"TRY002", # Create your own exception
"TRY003", # Avoid specifying long messages outside the exception class
"D10", # Missing docstring
Expand All @@ -334,7 +365,6 @@ ignore = [
"D418", # Function/Method decorated with @overload shouldn't contain a docstring (vscode supports it)
"PT013", # Found incorrect import of pytest, use simple import pytest instead (only for bad linters that can't check the qualname)
"TD002", # Missing author in TODO
"PGH003", # Use specific rule codes when ignoring type issues (covered by mypy)
"E701", # Multiple statements on one line (sometimes conflicts with black)
"CPY001", # missing-copyright-notice
"C901", # max-complexity
Expand Down
Loading

0 comments on commit 2b61f9c

Please sign in to comment.