Skip to content

Commit dd33185

Browse files
committed
mypy>=0.900 support
1 parent e5ee223 commit dd33185

File tree

5 files changed

+141
-113
lines changed

5 files changed

+141
-113
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Check http://editorconfig.org for more information
2+
# This is the main config file for this project:
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
end_of_line = lf
9+
indent_style = space
10+
insert_final_newline = true
11+
indent_size = 2
12+
13+
[*.py]
14+
indent_size = 4
15+
16+
[*.pyi]
17+
indent_size = 4
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
- case: reveal_type_extension_is_loaded
2-
main: |
3-
# if hook works, main should contain 'reveal_type(1)'
4-
reveal_type: 1
5-
out: |
6-
main:1: note: Revealed type is 'Literal[1]?'
7-
1+
- case: reveal_type_extension_is_loaded
2+
main: |
3+
# if hook works, main should contain 'reveal_type(1)'
4+
reveal_type: 1
5+
out: |
6+
main:1: note: Revealed type is "Literal[1]?"

pytest_mypy_plugins/tests/test-parametrized.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
- case: only_main
32
parametrized:
43
- a: 1
@@ -7,7 +6,9 @@
76
revealed_type: builtins.float
87
main: |
98
a = {{ a }}
10-
reveal_type(a) # N: Revealed type is '{{ revealed_type }}'
9+
reveal_type(a) # N: Revealed type is "{{ revealed_type }}"
10+
11+
1112
- case: with_extra
1213
parametrized:
1314
- a: 2
@@ -18,14 +19,16 @@
1819
rt: Any
1920
main: |
2021
import foo
21-
reveal_type(foo.test({{ a }}, {{ b }})) # N: Revealed type is '{{ rt }}'
22+
reveal_type(foo.test({{ a }}, {{ b }})) # N: Revealed type is "{{ rt }}"
2223
files:
2324
- path: foo.py
2425
content: |
2526
from typing import Any
2627
2728
def test(a: Any, b: Any) -> Any:
2829
...
30+
31+
2932
- case: with_out
3033
parametrized:
3134
- what: cat
@@ -40,5 +43,5 @@
4043
except Exception:
4144
...
4245
out: |
43-
main:2: note: Revealed type is '{{ rt }}'
46+
main:2: note: Revealed type is "{{ rt }}"
4447
main:4: error: Unsupported operand types for / ("str" and "int")
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
- case: mypy_path_from_env
2-
main: |
3-
from pair import Pair
1+
- case: mypy_path_from_env
2+
main: |
3+
from pair import Pair
44
5-
a: Pair
6-
reveal_type(a) # N: Revealed type is 'pair.Pair'
7-
env:
8-
- MYPYPATH=./pytest_mypy_plugins/tests/fixtures
5+
a: Pair
6+
reveal_type(a) # N: Revealed type is "pair.Pair"
7+
env:
8+
- MYPYPATH=./pytest_mypy_plugins/tests/fixtures
99

1010

11-
- case: mypy_path_from_env_with_error
12-
main: |
13-
from pair import Missing
14-
out: |
15-
main:1: error: Module 'pair' has no attribute 'Missing'
16-
env:
17-
- MYPYPATH=./pytest_mypy_plugins/tests/fixtures
11+
- case: mypy_path_from_env_with_error
12+
main: |
13+
from pair import Missing
14+
out: |
15+
main:1: error: Module "pair" has no attribute "Missing"
16+
env:
17+
- MYPYPATH=./pytest_mypy_plugins/tests/fixtures
1818

1919

20-
- case: add_mypypath_env_var_to_package_search
21-
main: |
22-
import extra_module
23-
env:
24-
- MYPYPATH=./extras
25-
files:
26-
- path: extras/extra_module.py
27-
content: |
28-
def extra_fn():
29-
pass
20+
- case: add_mypypath_env_var_to_package_search
21+
main: |
22+
import extra_module
23+
env:
24+
- MYPYPATH=./extras
25+
files:
26+
- path: extras/extra_module.py
27+
content: |
28+
def extra_fn():
29+
pass
Lines changed: 87 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,90 @@
1-
- case: simplest_case
2-
main: |
3-
a = 1
4-
b = 'hello'
1+
- case: simplest_case
2+
main: |
3+
a = 1
4+
b = 'hello'
55
6-
class MyClass:
6+
class MyClass:
7+
pass
8+
9+
reveal_type(a) # N: Revealed type is "builtins.int"
10+
reveal_type(b) # N: Revealed type is "builtins.str"
11+
12+
13+
- case: revealed_type_with_environment
14+
main: |
15+
a = 1
16+
class MyClass:
17+
def __init__(self):
718
pass
819
9-
reveal_type(a) # N: Revealed type is 'builtins.int'
10-
reveal_type(b) # N: Revealed type is 'builtins.str'
11-
12-
- case: revealed_type_with_environment
13-
main: |
14-
a = 1
15-
class MyClass:
16-
def __init__(self):
17-
pass
18-
19-
b = 'hello'
20-
21-
reveal_type(a) # N: Revealed type is 'builtins.int'
22-
reveal_type(b) # N: Revealed type is 'builtins.str'
23-
env:
24-
- DJANGO_SETTINGS_MODULE=mysettings
25-
26-
- case: revealed_type_with_disabled_cache
27-
main: |
28-
a = 1
29-
reveal_type(a) # N: Revealed type is 'builtins.int'
30-
disable_cache: true
31-
32-
- case: external_output_lines
33-
main: |
34-
a = 1
35-
reveal_type(a)
36-
out: |
37-
main:2: note: Revealed type is 'builtins.int'
38-
39-
- case: create_files
40-
main: |
41-
a = 1
42-
reveal_type(a) # N: Revealed type is 'builtins.int'
43-
files:
44-
- path: myapp/__init__.py
45-
- path: myapp/models.py
46-
content: |
47-
from django.db import models
48-
class MyModel:
49-
pass
50-
- path: myapp/apps.py
51-
52-
- case: error_case
53-
main: |
54-
a = 1
55-
a.lower() # E: "int" has no attribute "lower"
56-
57-
- case: custom_mypy_config_strict_optional_true_set
58-
main: |
59-
from typing import Optional
60-
a: Optional[int] = None
61-
a + 1
62-
mypy_config: |
63-
strict_optional = False
64-
65-
- case: skip_incorrect_test_case
66-
skip: yes
67-
main: |
68-
a = 1
69-
reveal_type(a) # N: boom!
70-
71-
- case: skip_if_true
72-
skip: sys.version_info > (2, 0)
73-
main: |
74-
a = 1
75-
a.lower() # E: boom!
76-
77-
- case: skip_if_false
78-
skip: sys.version_info > (20, 0)
79-
main: |
80-
a = 1
81-
a.lower() # E: "int" has no attribute "lower"
20+
b = 'hello'
21+
22+
reveal_type(a) # N: Revealed type is "builtins.int"
23+
reveal_type(b) # N: Revealed type is "builtins.str"
24+
env:
25+
- DJANGO_SETTINGS_MODULE=mysettings
26+
27+
28+
- case: revealed_type_with_disabled_cache
29+
main: |
30+
a = 1
31+
reveal_type(a) # N: Revealed type is "builtins.int"
32+
disable_cache: true
33+
34+
35+
- case: external_output_lines
36+
main: |
37+
a = 1
38+
reveal_type(a)
39+
out: |
40+
main:2: note: Revealed type is "builtins.int"
41+
42+
43+
- case: create_files
44+
main: |
45+
a = 1
46+
reveal_type(a) # N: Revealed type is "builtins.int"
47+
files:
48+
- path: myapp/__init__.py
49+
- path: myapp/models.py
50+
content: |
51+
from django.db import models
52+
class MyModel:
53+
pass
54+
- path: myapp/apps.py
55+
56+
57+
- case: error_case
58+
main: |
59+
a = 1
60+
a.lower() # E: "int" has no attribute "lower"
61+
62+
63+
- case: custom_mypy_config_strict_optional_true_set
64+
main: |
65+
from typing import Optional
66+
a: Optional[int] = None
67+
a + 1
68+
mypy_config: |
69+
strict_optional = False
70+
71+
72+
- case: skip_incorrect_test_case
73+
skip: yes
74+
main: |
75+
a = 1
76+
reveal_type(a) # N: boom!
77+
78+
79+
- case: skip_if_true
80+
skip: sys.version_info > (2, 0)
81+
main: |
82+
a = 1
83+
a.lower() # E: boom!
84+
85+
86+
- case: skip_if_false
87+
skip: sys.version_info < (0, 0)
88+
main: |
89+
a = 1
90+
a.lower() # E: "int" has no attribute "lower"

0 commit comments

Comments
 (0)