Skip to content

Commit

Permalink
Make mypy less strict
Browse files Browse the repository at this point in the history
In particular, this does not require files to be fully typed anymore.

I also added a couple of TODOs for checks we would want to eventually enable.
  • Loading branch information
Swatinem committed Sep 9, 2024
1 parent 5409f26 commit 0bd6afd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 17 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ jobs:
patch-typing-check:
name: Run Patch Type Check
uses: codecov/gha-workflows/.github/workflows/mypy.yml@00043f8fbe820934312f7fade4ea72ea92231b5e
with:
extra_config: "--explicit-package-bases"
2 changes: 1 addition & 1 deletion helpers/tests/pathmap/test_pathmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def test_clean_path():
assert _clean_path(path) == "some/directory"
path = "some/path\r/with/tabs\r"
assert _clean_path(path) == "some/path/with/tabs"
path = "some\ very_long/directory\ name"
path = "some\\ very_long/directory\\ name"
assert _clean_path(path) == "some very_long/directory name"
path = "ms\\style\\directory"
assert _clean_path(path) == "ms/style/directory"
Expand Down
21 changes: 15 additions & 6 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Global options:

[mypy]
disallow_untyped_defs = True
ignore_missing_imports = True
explicit_package_bases = True
; disable type checks in tests (for now):
exclude = tests

; TODO: we eventually want these errors to be enabled:
disable_error_code = attr-defined,import-untyped,name-defined
follow_imports = silent
exclude = test_.*\.py$

; TODO: and we would also want these additional checks to be enabled
; as they are defined in Sentry as well:
; check_untyped_defs = True
; no_implicit_reexport = True
; warn_unreachable = True
; warn_unused_configs = True
; warn_unused_ignores = True
; warn_redundant_casts = True
; enable_error_code = ignore-without-code,redundant-self
2 changes: 1 addition & 1 deletion services/failure_normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FailureNormalizer:
Usage:
dict_of_regex_strings = [
"DATE": r"(\d{4}-\d{2}-\d{2})",
"DATE": r"(\\d{4}-\\d{2}-\\d{2})",
]
f = FailureNormalizer(dict_of_regex_strings)
Expand Down
8 changes: 4 additions & 4 deletions services/notification/notifiers/tests/unit/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,7 @@ async def test_build_message_no_base_report(
"",
f"| [Files with missing lines](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?dropdown=coverage&src=pr&el=tree) | Coverage Δ | Complexity Δ | |",
"|---|---|---|---|",
f"| [file\_1.go](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=tree&filepath=file_1.go#diff-ZmlsZV8xLmdv) | `62.50% <66.67%> (ø)` | `10.00 <0.00> (?)` | |",
f"| [file\\_1.go](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=tree&filepath=file_1.go#diff-ZmlsZV8xLmdv) | `62.50% <66.67%> (ø)` | `10.00 <0.00> (?)` | |",
"",
"------",
"",
Expand Down Expand Up @@ -1458,7 +1458,7 @@ async def test_build_message_no_base_commit(
"",
f"| [Files with missing lines](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?dropdown=coverage&src=pr&el=tree) | Coverage Δ | Complexity Δ | |",
"|---|---|---|---|",
f"| [file\_1.go](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=tree&filepath=file_1.go#diff-ZmlsZV8xLmdv) | `62.50% <66.67%> (ø)` | `10.00 <0.00> (?)` | |",
f"| [file\\_1.go](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=tree&filepath=file_1.go#diff-ZmlsZV8xLmdv) | `62.50% <66.67%> (ø)` | `10.00 <0.00> (?)` | |",
"",
"------",
"",
Expand Down Expand Up @@ -4219,7 +4219,7 @@ async def test_build_message_no_base_commit_new_layout(
"",
f"| [Files with missing lines](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?dropdown=coverage&src=pr&el=tree) | Coverage Δ | Complexity Δ | |",
"|---|---|---|---|",
f"| [file\_1.go](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=tree&filepath=file_1.go#diff-ZmlsZV8xLmdv) | `62.50% <66.67%> (ø)` | `10.00 <0.00> (?)` | |",
f"| [file\\_1.go](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=tree&filepath=file_1.go#diff-ZmlsZV8xLmdv) | `62.50% <66.67%> (ø)` | `10.00 <0.00> (?)` | |",
"",
"",
f"[:umbrella: View full report in Codecov by Sentry](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?dropdown=coverage&src=pr&el=continue). ",
Expand Down Expand Up @@ -4291,7 +4291,7 @@ async def test_build_message_no_base_report_new_layout(
"",
f"| [Files with missing lines](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?dropdown=coverage&src=pr&el=tree) | Coverage Δ | Complexity Δ | |",
"|---|---|---|---|",
f"| [file\_1.go](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=tree&filepath=file_1.go#diff-ZmlsZV8xLmdv) | `62.50% <66.67%> (ø)` | `10.00 <0.00> (?)` | |",
f"| [file\\_1.go](test.example.br/gh/{repository.slug}/pull/{pull.pullid}?src=pr&el=tree&filepath=file_1.go#diff-ZmlsZV8xLmdv) | `62.50% <66.67%> (ø)` | `10.00 <0.00> (?)` | |",
"",
"</details>",
"",
Expand Down
6 changes: 3 additions & 3 deletions services/report/languages/tests/unit/test_vb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from services.report.languages import vb
from test_utils.base import BaseTestCase

txt = """<?xml version="1.0" encoding="UTF-8" ?>
txt = """<?xml version="1.0" encoding="UTF-8"?>
<results>
<modules>
<module name="riosock.dll" path="riosock.dll" id="A8980752D35C194D988F77B70FC7950101000000" block_coverage="59.29" line_coverage="66.67" blocks_covered="166" blocks_not_covered="114" lines_covered="186" lines_partially_covered="4" lines_not_covered="89">
Expand All @@ -29,9 +29,9 @@
</function>
</functions>
<source_files>
<source_file id="0" path="Source\Mobius\csharp\Tests.Common\RowHelper.cs">
<source_file id="0" path="Source\\Mobius\\csharp\\Tests.Common\\RowHelper.cs">
</source_file>
<source_file id="1" path="Source\Mobius\csharp\Tests.Common\Picklers.cs">
<source_file id="1" path="Source\\Mobius\\csharp\\Tests.Common\\Picklers.cs">
</source_file>
</source_files>
</module>
Expand Down

0 comments on commit 0bd6afd

Please sign in to comment.