Skip to content

Commit

Permalink
DX: recommend and configure VSCode mypy extension (#153)
Browse files Browse the repository at this point in the history
* FIX: ignore `jsonschema` deprecation warning
* MAINT: autoupdate pre-commit hooks
* MAINT: remove `extract_extensions_test`
  • Loading branch information
redeboer authored Jul 6, 2023
1 parent f2e22bf commit 467bc74
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ vscode:
- garaioag.garaio-vscode-unwanted-recommendations
- github.vscode-github-actions
- github.vscode-pull-request-github
- ms-python.mypy-type-checker
- ms-python.python
- ms-python.vscode-pylance
- ms-vsliveshare.vsliveshare
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ repos:
- python

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
rev: v3.0.0
hooks:
- id: prettier

Expand All @@ -119,7 +119,7 @@ repos:
- --py36-plus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.276
rev: v0.0.277
hooks:
- id: ruff
args:
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"garaioag.garaio-vscode-unwanted-recommendations",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"ms-python.mypy-type-checker",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vsliveshare.vsliveshare",
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@
},
"git.rebaseWhenSync": true,
"github-actions.workflows.pinned.workflows": [".github/workflows/ci.yml"],
"mypy-type-checker.importStrategy": "fromEnvironment",
"python.analysis.autoImportCompletions": false,
"python.analysis.inlayHints.pytestParameters": true,
"python.analysis.typeCheckingMode": "strict",
"python.formatting.provider": "black",
"python.linting.banditEnabled": false,
"python.linting.enabled": true,
"python.linting.flake8Enabled": false,
"python.linting.mypyEnabled": true,
"python.linting.mypyEnabled": false,
"python.linting.pydocstyleEnabled": false,
"python.linting.pylamaEnabled": false,
"python.linting.pylintEnabled": false,
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ addopts = """
--doctest-modules
--durations=3
"""
filterwarnings = ["error"]
filterwarnings = [
"error",
"ignore: Importing ErrorTree directly from the jsonschema package is deprecated.*",
]
markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"]
testpaths = [
"src",
Expand Down
14 changes: 13 additions & 1 deletion src/repoma/check_dev_files/mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@

from repoma.errors import PrecommitError
from repoma.utilities import CONFIG_PATH
from repoma.utilities.executor import Executor
from repoma.utilities.pyproject import get_sub_table, load_pyproject, write_pyproject
from repoma.utilities.vscode import add_extension_recommendation, set_setting


def main() -> None:
_merge_mypy_into_pyproject()
executor = Executor()
executor(_merge_mypy_into_pyproject)
executor(add_extension_recommendation, "ms-python.mypy-type-checker")
executor(
set_setting,
{
"mypy-type-checker.importStrategy": "fromEnvironment",
"python.linting.mypyEnabled": False,
},
)
executor.finalize()


def _merge_mypy_into_pyproject() -> None:
Expand Down
26 changes: 0 additions & 26 deletions tests/check_dev_files/test_gitpod.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,6 @@
from repoma.check_dev_files.gitpod import _extract_extensions, _generate_gitpod_config


def test_extract_extensions():
assert _extract_extensions() == [
# cspell:disable
"charliermarsh.ruff",
"christian-kohler.path-intellisense",
"davidanson.vscode-markdownlint",
"eamodio.gitlens",
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"garaioag.garaio-vscode-unwanted-recommendations",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vsliveshare.vsliveshare",
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters",
"stkb.rewrap",
"streetsidesoftware.code-spell-checker",
"tamasfe.even-better-toml",
"tyriar.sort-lines",
"yzhang.markdown-all-in-one",
# cspell:enable
]


@pytest.mark.parametrize("pin_dependencies", [False, True])
def test_get_gitpod_content(pin_dependencies: bool):
gitpod_content = _generate_gitpod_config(pin_dependencies)
Expand Down

0 comments on commit 467bc74

Please sign in to comment.