Skip to content

Commit

Permalink
type ignore comments compatibility between pyright and mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed May 24, 2024
1 parent c0f8cfd commit fe18e5d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ jobs:
- name: Run pytest tests
run: PYTHONPATH='.' pytest --num-shards=4 --shard-id=${{ matrix.shard }} tests
- name: Run mypy on the test cases
# TODO: When mypy aligns with pyright, remove the `--no-warn-unused-ignores`.
run: mypy tests/assert_type --no-warn-unused-ignores
run: mypy tests/assert_type

stubtest:
timeout-minutes: 10
Expand Down
4 changes: 2 additions & 2 deletions pyrightconfig.testcases.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"reportImplicitStringConcatenation": "error",
"reportUninitializedInstanceVariable": "error",
"reportUnnecessaryTypeIgnoreComment": "error",
// Using unspecific `type: ignore` comments in test_cases.
"enableTypeIgnoreComments": true,
// Don't use '# type: ignore' to suppress with pyright
"enableTypeIgnoreComments": false,
// If a test case uses this anti-pattern, there's likely a reason and annoying to `type: ignore`.
// Let Ruff flag it (B006)
"reportCallInDefaultInitializer": "none",
Expand Down
8 changes: 4 additions & 4 deletions tests/assert_type/db/models/check_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
class MyIntegerChoices(IntegerChoices):
A = 1
B = 2, "B"
C = 3, "B", "..." # type: ignore
C = 3, "B", "..." # pyright: ignore[reportCallIssue]
D = 4, _("D")
E = 5, 1 # type: ignore
E = 5, 1 # pyright: ignore[reportArgumentType]
F = "1"


Expand All @@ -29,8 +29,8 @@ class MyTextChoices(TextChoices):
A = "a"
B = "b", "B"
C = "c", _("C")
D = 1 # type: ignore
E = "e", 1 # type: ignore
D = 1 # pyright: ignore[reportArgumentType]
E = "e", 1 # pyright: ignore[reportArgumentType]


assert_type(MyTextChoices.A, Literal[MyTextChoices.A])
Expand Down

0 comments on commit fe18e5d

Please sign in to comment.