From 4a9ce278638c797d1a5fb39b38a0add473d99033 Mon Sep 17 00:00:00 2001 From: Eli Schleifer Date: Wed, 23 Aug 2023 14:39:12 -0700 Subject: [PATCH 1/2] --- .trunk/trunk.yaml | 1 + linters/mypy/test_data/a.py | 4 ++++ linters/mypy/test_data/b.py | 5 +++++ 3 files changed, 10 insertions(+) create mode 100644 linters/mypy/test_data/a.py create mode 100644 linters/mypy/test_data/b.py diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index a948d4209..aa6e01122 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -43,6 +43,7 @@ lint: list: ["${linter}"] enabled: + - mypy@1.5.1 - actionlint@1.6.23 - black@23.1.0 - eslint@8.36.0 diff --git a/linters/mypy/test_data/a.py b/linters/mypy/test_data/a.py new file mode 100644 index 000000000..4ab6b1de6 --- /dev/null +++ b/linters/mypy/test_data/a.py @@ -0,0 +1,4 @@ +from . import mypy_import2 + +def double(value: int) -> int: + return value + value diff --git a/linters/mypy/test_data/b.py b/linters/mypy/test_data/b.py new file mode 100644 index 000000000..7925a54d8 --- /dev/null +++ b/linters/mypy/test_data/b.py @@ -0,0 +1,5 @@ +from .a import double + + +def triple(value: int) -> int: + return double(value) + value From 73a25ff6a20593010847d410c976acc566676a92 Mon Sep 17 00:00:00 2001 From: Eli Schleifer Date: Wed, 23 Aug 2023 16:29:49 -0700 Subject: [PATCH 2/2] --- .trunk/trunk.yaml | 3 +++ linters/mypy/plugin.yaml | 41 +++++++++++++++++++++++++++++++++++-- linters/mypy/test_data/a.py | 4 +--- 3 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index aa6e01122..207174c69 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -65,6 +65,9 @@ lint: paths: - "**/test_data" # required for golangci-lint, which runs on directories - "**/test_data/**" + - linters: [mypy] + paths: + - "**/test_data/autopep8/**" actions: definitions: diff --git a/linters/mypy/plugin.yaml b/linters/mypy/plugin.yaml index f9a4c7eb9..5ab4f4ffa 100644 --- a/linters/mypy/plugin.yaml +++ b/linters/mypy/plugin.yaml @@ -4,14 +4,24 @@ lint: - name: mypy files: [python] commands: - - name: lint + # - name: lint + # # Custom parser type defined in the trunk cli to handle mypy's output. + # output: mypy + # run: + # mypy --ignore-missing-imports --follow-imports=silent --show-error-codes + # --show-column-numbers ${target} + # success_codes: [0, 1] + # stdin: false + - name: lint-ci # Custom parser type defined in the trunk cli to handle mypy's output. output: mypy run: mypy --ignore-missing-imports --follow-imports=silent --show-error-codes - --show-column-numbers ${target} + --show-column-numbers ${workspace} success_codes: [0, 1] stdin: false + target: ${root_or_parent_with(file_that_will_never_exist)} + run_when: [ci] runtime: python package: mypy direct_configs: @@ -26,3 +36,30 @@ lint: version_command: parse_regex: ${semver} run: mypy --version + # - name: mypy-all + # files: [python] + # commands: + # - name: lint + # # Custom parser type defined in the trunk cli to handle mypy's output. + # output: mypy + # run: + # mypy --ignore-missing-imports --follow-imports=silent --show-error-codes + # --show-column-numbers + # success_codes: [0, 1] + # stdin: false + # target: ${root_or_parent_with(file_that_will_never_exist)} + # runtime: python + # package: mypy + # run_when: [ci, cli] + # direct_configs: + # - mypy.ini + # - .mypy.ini + # affects_cache: + # - pyproject.toml + # - setup.cfg + # is_recommended: false + # issue_url_format: https://mypy.readthedocs.io/en/stable/error_code_list.html + # known_good_version: 0.931 + # version_command: + # parse_regex: ${semver} + # run: mypy --version diff --git a/linters/mypy/test_data/a.py b/linters/mypy/test_data/a.py index 4ab6b1de6..bf1683b04 100644 --- a/linters/mypy/test_data/a.py +++ b/linters/mypy/test_data/a.py @@ -1,4 +1,2 @@ -from . import mypy_import2 - -def double(value: int) -> int: +def double(value: str) -> str: return value + value