Skip to content

Commit

Permalink
Merge pull request #15 from jorenham/basedmypy
Browse files Browse the repository at this point in the history
Based mypy
  • Loading branch information
jorenham authored Aug 19, 2024
2 parents 05a28e8 + f76c1e5 commit 7b8c082
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ jobs:
- name: basedpyright --verifytypes
run: poetry run basedpyright --ignoreexternal --verifytypes exports

# - name: mypy
# run: poetry run mypy .
- name: basedmypy
run: poetry run mypy .

test:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,9 @@ repos:
language: system
always_run: true
pass_filenames: false

- id: basedmypy
name: basedmypy
entry: poetry run mypy
language: system
types_or: [python, pyi]
6 changes: 4 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"recommendations": [
"charliermarsh.ruff",
"davidanson.vscode-markdownlint",
"ms-python.vscode-pylance",
"detachhead.basedpyright",
"ms-python.mypy-type-checker",
"ms-python.python"
]
],
"unwantedRecommendations": ["ms-pyright.pyright", "ms-python.vscode-pylance"]
}
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"editor.rulers": [88],
"git.branchProtection": ["master"]
"git.branchProtection": ["master"],
"mypy-type-checker.args": [
"--config-file=pyproject.toml"
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
src="https://img.shields.io/badge/pre--commit-enabled-orange?logo=pre-commit"
/>
</a>
<!-- <a href="https://github.com/KotlinIsland/basedmypy">
<a href="https://github.com/KotlinIsland/basedmypy">
<img
alt="exports - basedmypy"
src="https://img.shields.io/badge/basedmypy-checked-fd9002"
/>
</a> -->
</a>
<a href="https://detachhead.github.io/basedpyright">
<img
alt="exports - basedpyright"
Expand Down
3 changes: 2 additions & 1 deletion exports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def export(obj: _T | str, /, *, threadsafe: bool = False) -> Callable[[_T], _T]
if module is None:
raise ModuleNotFoundError(f'could not find module of {obj!r}')

res: Callable[[_T], _T] | _T
if isinstance(obj, str):
name = obj
res = _identity
Expand All @@ -86,7 +87,7 @@ def export(obj: _T | str, /, *, threadsafe: bool = False) -> Callable[[_T], _T]
warnings.warn(f'{name!r} already exported', stacklevel=2)
else:
exports.append(name)
module.__all__ = exports # pyright: ignore[reportAttributeAccessIssue]
module.__all__ = exports # type: ignore[attr-defined] # pyright: ignore[reportAttributeAccessIssue]

return res

Expand Down
75 changes: 74 additions & 1 deletion poetry.lock

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

19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ packages = [{include = "exports"}] # don't remove
python = "^3.8"

[tool.poetry.group.dev.dependencies]
basedmypy = "^2.6.0"
basedpyright = "^1.16.0"
codespell = "^2.3.0"
pre-commit = [
Expand All @@ -57,6 +58,24 @@ skip = '*.lock,.venv,.vscode,dist'
context = 2


[tool.mypy]
python_version = "3.10"
always_true = "NP2"
always_false = "NP20"
modules = ["optype", "tests"]
exclude = ["^.venv/.*", "tests/*"]
strict = true

disallow_untyped_defs = true
disallow_incomplete_defs = true
show_error_code_links = true
warn_redundant_casts = true
warn_unused_ignores = true
# based
disallow_any_expr = false # https://github.com/numpy/numpy/pull/27211
disallow_any_explicit = false
disallow_any_decorated = false

[tool.pyright]
include = ["exports"]
exclude = [".venv", "tests"]
Expand Down

0 comments on commit 7b8c082

Please sign in to comment.