diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index d034821ab..0d0a231bf 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -19,16 +19,20 @@ plugins: lint: # enabled linters inherited from github.com/trunk-io/configs plugin - enabled: [] - + enabled: + - mypy@1.5.1 disabled: - pylint # pylint diagnostics are too strict + ignore: - linters: [ALL] 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 150bd8011..28b6d4c04 100644 --- a/linters/mypy/plugin.yaml +++ b/linters/mypy/plugin.yaml @@ -11,14 +11,26 @@ lint: - name: mypy files: [python, python-interface] 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 tools: [mypy] direct_configs: - mypy.ini @@ -32,3 +44,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 new file mode 100644 index 000000000..bf1683b04 --- /dev/null +++ b/linters/mypy/test_data/a.py @@ -0,0 +1,2 @@ +def double(value: str) -> str: + 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