diff --git a/linters/mypy/mypy.test.ts b/linters/mypy/mypy.test.ts index 45a651d30..639304d12 100644 --- a/linters/mypy/mypy.test.ts +++ b/linters/mypy/mypy.test.ts @@ -7,7 +7,7 @@ const versionGreaterThanOrEqual = (a: string, b: string) => [a.split(".")] >= [b const manualVersionReplacer = (version: string) => { const [major, minor] = version.split(".").map((part) => Number.parseInt(part, 10)); if (!Number.isNaN(major) && !Number.isNaN(minor) && major === 1 && minor >= 20) { - return "1.18.2"; + return "1.20.2"; } return version; }; diff --git a/linters/mypy/plugin.yaml b/linters/mypy/plugin.yaml index 602fef806..aa4fde671 100644 --- a/linters/mypy/plugin.yaml +++ b/linters/mypy/plugin.yaml @@ -5,7 +5,7 @@ tools: runtime: python package: mypy shims: [mypy] - known_good_version: 1.18.2 + known_good_version: 1.20.2 lint: definitions: - name: mypy @@ -14,6 +14,18 @@ lint: commands: - name: lint # Custom parser type defined in the trunk cli to handle mypy's output. + version: ">=1.20.0" + output: mypy + run: + mypy --ignore-missing-imports --follow-imports=silent --show-error-codes + --show-column-numbers --no-incremental ${target} + run_from: ${root_or_parent_with_any_config} + batch: true + success_codes: [0, 1] + stdin: false + - name: lint + # Custom parser type defined in the trunk cli to handle mypy's output. + version: <1.20.0 output: mypy run: mypy --ignore-missing-imports --follow-imports=silent --show-error-codes @@ -30,7 +42,7 @@ lint: - setup.cfg suggest_if: config_present issue_url_format: https://mypy.readthedocs.io/en/stable/error_code_list.html - known_good_version: 1.18.2 + known_good_version: 1.20.2 version_command: parse_regex: ${semver} run: mypy --version diff --git a/linters/mypy/test_data/mypy_v1.20.2_CUSTOM.check.shot b/linters/mypy/test_data/mypy_v1.20.2_CUSTOM.check.shot new file mode 100644 index 000000000..c88c849d4 --- /dev/null +++ b/linters/mypy/test_data/mypy_v1.20.2_CUSTOM.check.shot @@ -0,0 +1,141 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Testing linter mypy test CUSTOM 1`] = ` +{ + "issues": [ + { + "code": "arg-type", + "column": "10", + "file": "test_data/basic.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://mypy.readthedocs.io/en/stable/error_code_list.html", + "level": "LEVEL_HIGH", + "line": "13", + "linter": "mypy", + "message": "Argument 1 to "greeting" has incompatible type "int"; expected "str"", + "targetType": "python", + }, + { + "code": "arg-type", + "column": "10", + "file": "test_data/basic.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://mypy.readthedocs.io/en/stable/error_code_list.html", + "level": "LEVEL_HIGH", + "line": "14", + "linter": "mypy", + "message": "Argument 1 to "greeting" has incompatible type "bytes"; expected "str"", + "targetType": "python", + }, + { + "code": "func-returns-value", + "column": "5", + "file": "test_data/basic.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://mypy.readthedocs.io/en/stable/error_code_list.html", + "level": "LEVEL_HIGH", + "line": "15", + "linter": "mypy", + "message": ""printer" does not return a value (it only ever returns None)", + "targetType": "python", + }, + { + "code": "assignment", + "column": "10", + "file": "test_data/basic.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://mypy.readthedocs.io/en/stable/error_code_list.html", + "level": "LEVEL_HIGH", + "line": "16", + "linter": "mypy", + "message": "Incompatible types in assignment (expression has type "int", variable has type "str")", + "targetType": "python", + }, + { + "code": "attr-defined", + "column": "1", + "file": "test_data/basic.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://mypy.readthedocs.io/en/stable/error_code_list.html", + "level": "LEVEL_HIGH", + "line": "3", + "linter": "mypy", + "message": "Module "test_data" has no attribute "mypy_import2"", + "targetType": "python", + }, + { + "code": "return", + "column": "1", + "file": "test_data/source.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://mypy.readthedocs.io/en/stable/error_code_list.html", + "level": "LEVEL_HIGH", + "line": "8", + "linter": "mypy", + "message": "Missing return statement", + "targetType": "python", + }, + ], + "lintActions": [ + { + "command": "lint", + "fileGroupName": "python", + "linter": "mypy", + "paths": [ + "test_data/__init__.py", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "python", + "linter": "mypy", + "paths": [ + "test_data/basic.py", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "python", + "linter": "mypy", + "paths": [ + "test_data/source.py", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "python", + "linter": "mypy", + "paths": [ + "test_data/__init__.py", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "python", + "linter": "mypy", + "paths": [ + "test_data/basic.py", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "python", + "linter": "mypy", + "paths": [ + "test_data/source.py", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + ], + "taskFailures": [], + "unformattedFiles": [], +} +`;