Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2938d10

Browse files
Michael0x2agvanrossum
authored andcommitted
Rename fixtures and lib-stub files to end in pyi, not py (#2026)
This commit will eventually make integrating silent_imports into the unit tests easier. It also makes it easier to mirror changes between typeshed and the mypy test suites.
1 parent 872d198 commit 2938d10

82 files changed

Lines changed: 723 additions & 723 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

mypy/stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def dump_type_stats(tree: Node, path: str, inferred: bool = False,
222222

223223

224224
def is_special_module(path: str) -> bool:
225-
return os.path.basename(path) in ('abc.py', 'typing.py', 'builtins.py')
225+
return os.path.basename(path) in ('abc.pyi', 'typing.pyi', 'builtins.pyi')
226226

227227

228228
def is_imprecise(t: Type) -> bool:

mypy/test/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ def parse_test_cases(
5757
mpath = os.path.join(os.path.dirname(path), p[i].arg)
5858
f = open(mpath)
5959
if p[i].id == 'builtins':
60-
fnam = 'builtins.py'
60+
fnam = 'builtins.pyi'
6161
else:
6262
# Python 2
63-
fnam = '__builtin__.py'
63+
fnam = '__builtin__.pyi'
6464
files.append((os.path.join(base_path, fnam), f.read()))
6565
f.close()
6666
elif p[i].id == 'stale':

mypy/test/testsemanal.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ def test_semanal(testcase):
7575
# Omit the builtins module and files with a special marker in the
7676
# path.
7777
# TODO the test is not reliable
78-
if (not f.path.endswith((os.sep + 'builtins.py',
79-
'typing.py',
80-
'abc.py',
81-
'collections.py'))
78+
if (not f.path.endswith((os.sep + 'builtins.pyi',
79+
'typing.pyi',
80+
'abc.pyi',
81+
'collections.pyi'))
8282
and not os.path.basename(f.path).startswith('_')
8383
and not os.path.splitext(
8484
os.path.basename(f.path))[0].endswith('_')):

mypy/test/testtransform.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def test_transform(testcase):
6060
# Omit the builtins module and files with a special marker in the
6161
# path.
6262
# TODO the test is not reliable
63-
if (not f.path.endswith((os.sep + 'builtins.py',
64-
'typing.py',
65-
'abc.py'))
63+
if (not f.path.endswith((os.sep + 'builtins.pyi',
64+
'typing.pyi',
65+
'abc.pyi'))
6666
and not os.path.basename(f.path).startswith('_')
6767
and not os.path.splitext(
6868
os.path.basename(f.path))[0].endswith('_')):

test-data/unit/check-abstract.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ class B(A):
617617
def x(self) -> int: pass
618618
b = B()
619619
b.x() # E: "int" not callable
620-
[builtins fixtures/property.py]
620+
[builtins fixtures/property.pyi]
621621

622622
[case testImplementReradWriteAbstractPropertyViaProperty]
623623
from abc import abstractproperty, ABCMeta
@@ -633,7 +633,7 @@ class B(A):
633633
def x(self, v: int) -> None: pass
634634
b = B()
635635
b.x.y # E: "int" has no attribute "y"
636-
[builtins fixtures/property.py]
636+
[builtins fixtures/property.pyi]
637637

638638
[case testImplementAbstractPropertyViaPropertyInvalidType]
639639
from abc import abstractproperty, ABCMeta
@@ -645,7 +645,7 @@ class B(A):
645645
def x(self) -> str: pass # E
646646
b = B()
647647
b.x() # E
648-
[builtins fixtures/property.py]
648+
[builtins fixtures/property.pyi]
649649
[out]
650650
main: note: In class "B":
651651
main:7: error: Return type of "x" incompatible with supertype "A"
@@ -662,7 +662,7 @@ class B(A):
662662
self.x = 1 # E
663663
b = B() # E
664664
b.x.y # E
665-
[builtins fixtures/property.py]
665+
[builtins fixtures/property.pyi]
666666
[out]
667667
main: note: In member "__init__" of class "B":
668668
main:7: error: Property "x" defined in "B" is read-only
@@ -679,7 +679,7 @@ class B(A):
679679
@property
680680
def x(self) -> int:
681681
return super().x.y # E: "int" has no attribute "y"
682-
[builtins fixtures/property.py]
682+
[builtins fixtures/property.pyi]
683683
[out]
684684
main: note: In member "x" of class "B":
685685

@@ -697,7 +697,7 @@ class B(A):
697697
@x.setter
698698
def x(self, v: int) -> None:
699699
super().x = '' # E
700-
[builtins fixtures/property.py]
700+
[builtins fixtures/property.pyi]
701701
[out]
702702
main: note: In member "x" of class "B":
703703
main:10: error: "int" has no attribute "y"
@@ -716,7 +716,7 @@ class B(A):
716716
def x(self) -> int: pass
717717
b = B()
718718
b.x.y # E
719-
[builtins fixtures/property.py]
719+
[builtins fixtures/property.pyi]
720720
[out]
721721
main: note: In class "B":
722722
main:8: error: Read-only property cannot override read-write property

test-data/unit/check-async-await.test

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@
55
# options: fast_parser
66
async def f() -> int:
77
pass
8-
[builtins fixtures/async_await.py]
8+
[builtins fixtures/async_await.pyi]
99

1010
[case testAsyncDefReturn]
1111
# options: fast_parser
1212
async def f() -> int:
1313
return 0
1414
reveal_type(f()) # E: Revealed type is 'typing.Awaitable[builtins.int]'
15-
[builtins fixtures/async_await.py]
15+
[builtins fixtures/async_await.pyi]
1616

1717
[case testAwaitCoroutine]
1818
# options: fast_parser
1919
async def f() -> int:
2020
x = await f()
2121
reveal_type(x) # E: Revealed type is 'builtins.int*'
2222
return x
23-
[builtins fixtures/async_await.py]
23+
[builtins fixtures/async_await.pyi]
2424
[out]
2525
main: note: In function "f":
2626

@@ -92,7 +92,7 @@ def g() -> int:
9292
async def f() -> int:
9393
x = await g()
9494
return x
95-
[builtins fixtures/async_await.py]
95+
[builtins fixtures/async_await.pyi]
9696
[out]
9797
main: note: In function "f":
9898
main:5: error: Incompatible types in await (actual type "int", expected type "Awaitable")
@@ -103,7 +103,7 @@ async def g() -> int:
103103
return 0
104104
async def f() -> str:
105105
x = await g() # type: str
106-
[builtins fixtures/async_await.py]
106+
[builtins fixtures/async_await.pyi]
107107
[out]
108108
main: note: In function "f":
109109
main:5: error: Incompatible types in assignment (expression has type "int", variable has type "str")
@@ -115,7 +115,7 @@ async def g() -> int:
115115
async def f() -> str:
116116
x = await g()
117117
return x
118-
[builtins fixtures/async_await.py]
118+
[builtins fixtures/async_await.pyi]
119119
[out]
120120
main: note: In function "f":
121121
main:6: error: Incompatible return value type (got "int", expected "str")
@@ -128,7 +128,7 @@ class C(AsyncIterator[int]):
128128
async def f() -> None:
129129
async for x in C():
130130
reveal_type(x) # E: Revealed type is 'builtins.int*'
131-
[builtins fixtures/async_await.py]
131+
[builtins fixtures/async_await.pyi]
132132
[out]
133133
main: note: In function "f":
134134

@@ -138,7 +138,7 @@ from typing import AsyncIterator
138138
async def f() -> None:
139139
async for x in [1]:
140140
pass
141-
[builtins fixtures/async_await.py]
141+
[builtins fixtures/async_await.pyi]
142142
[out]
143143
main: note: In function "f":
144144
main:4: error: AsyncIterable expected
@@ -152,7 +152,7 @@ class C:
152152
async def f() -> None:
153153
async with C() as x:
154154
reveal_type(x) # E: Revealed type is 'builtins.int*'
155-
[builtins fixtures/async_await.py]
155+
[builtins fixtures/async_await.pyi]
156156
[out]
157157
main: note: In function "f":
158158

@@ -164,7 +164,7 @@ class C:
164164
async def f() -> None:
165165
async with C() as x:
166166
pass
167-
[builtins fixtures/async_await.py]
167+
[builtins fixtures/async_await.pyi]
168168
[out]
169169
main: note: In function "f":
170170
main:6: error: "C" has no attribute "__aenter__"; maybe "__enter__"?
@@ -178,7 +178,7 @@ class C:
178178
async def f() -> None:
179179
async with C() as x: # E: Incompatible types in "async with" for __aenter__ (actual type "int", expected type "Awaitable")
180180
pass
181-
[builtins fixtures/async_await.py]
181+
[builtins fixtures/async_await.pyi]
182182
[out]
183183
main: note: In function "f":
184184

@@ -190,7 +190,7 @@ class C:
190190
async def f() -> None:
191191
async with C() as x: # E: "__aenter__" of "C" does not return a value
192192
pass
193-
[builtins fixtures/async_await.py]
193+
[builtins fixtures/async_await.pyi]
194194
[out]
195195
main: note: In function "f":
196196

@@ -202,7 +202,7 @@ class C:
202202
async def f() -> None:
203203
async with C() as x: # E: Incompatible types in "async with" for __aexit__ (actual type "int", expected type "Awaitable")
204204
pass
205-
[builtins fixtures/async_await.py]
205+
[builtins fixtures/async_await.pyi]
206206
[out]
207207
main: note: In function "f":
208208

@@ -214,7 +214,7 @@ class C:
214214
async def f() -> None:
215215
async with C() as x: # E: "__aexit__" of "C" does not return a value
216216
pass
217-
[builtins fixtures/async_await.py]
217+
[builtins fixtures/async_await.pyi]
218218
[out]
219219
main: note: In function "f":
220220

@@ -226,7 +226,7 @@ async def g():
226226
yield
227227
async def h():
228228
x = yield
229-
[builtins fixtures/async_await.py]
229+
[builtins fixtures/async_await.pyi]
230230
[out]
231231
main: note: In function "f":
232232
main:3: error: 'yield' in async function
@@ -241,7 +241,7 @@ async def f():
241241
yield from []
242242
async def g():
243243
x = yield from []
244-
[builtins fixtures/async_await.py]
244+
[builtins fixtures/async_await.pyi]
245245
[out]
246246
main: note: In function "f":
247247
main:3: error: 'yield from' in async function
@@ -261,7 +261,7 @@ async def f() -> str:
261261
def g() -> Generator[Any, None, str]:
262262
x = yield from f()
263263
return x
264-
[builtins fixtures/async_await.py]
264+
[builtins fixtures/async_await.pyi]
265265
[out]
266266
main: note: In function "g":
267267
main:6: error: "yield from" can't be applied to Awaitable[str]
@@ -290,7 +290,7 @@ async def main() -> None:
290290
reveal_type(y) # E: Revealed type is 'builtins.int'
291291
async for z in I():
292292
reveal_type(z) # E: Revealed type is 'builtins.int'
293-
[builtins fixtures/async_await.py]
293+
[builtins fixtures/async_await.pyi]
294294
[out]
295295
main: note: In function "main":
296296

@@ -307,7 +307,7 @@ def f() -> Generator[int, str, int]:
307307
return 0
308308
else:
309309
return '' # E: Incompatible return value type (got "str", expected "int")
310-
[builtins fixtures/async_await.py]
310+
[builtins fixtures/async_await.pyi]
311311
[out]
312312
main: note: In function "f":
313313

@@ -397,5 +397,5 @@ async def decorated_host_coroutine() -> None:
397397
x = await other_iterator() # E: Incompatible types in await (actual type "It", expected type "Awaitable")
398398
x = await other_coroutine()
399399

400-
[builtins fixtures/async_await.py]
400+
[builtins fixtures/async_await.pyi]
401401
[out]

test-data/unit/check-basic.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,21 +223,21 @@ import typing
223223
x = __name__ # type: str
224224
a = __name__ # type: A # E: Incompatible types in assignment (expression has type "str", variable has type "A")
225225
class A: pass
226-
[builtins fixtures/primitives.py]
226+
[builtins fixtures/primitives.pyi]
227227

228228
[case testModule__doc__]
229229
import typing
230230
x = __doc__ # type: str
231231
a = __doc__ # type: A # E: Incompatible types in assignment (expression has type "str", variable has type "A")
232232
class A: pass
233-
[builtins fixtures/primitives.py]
233+
[builtins fixtures/primitives.pyi]
234234

235235
[case testModule__file__]
236236
import typing
237237
x = __file__ # type: str
238238
a = __file__ # type: A # E: Incompatible types in assignment (expression has type "str", variable has type "A")
239239
class A: pass
240-
[builtins fixtures/primitives.py]
240+
[builtins fixtures/primitives.pyi]
241241

242242
[case test__package__]
243243
import typing

test-data/unit/check-bound.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def f(x: T) -> T:
157157
return x
158158

159159
b = f(B())
160-
[builtins fixtures/property.py]
160+
[builtins fixtures/property.pyi]
161161
[out]
162162
main: note: In function "f":
163163

@@ -171,7 +171,7 @@ class A(A0): pass
171171
T = TypeVar('T', bound=A)
172172
def f(x: T) -> int:
173173
return x.foo(22)
174-
[builtins fixtures/classmethod.py]
174+
[builtins fixtures/classmethod.pyi]
175175

176176

177177
[case testBoundStaticMethod]
@@ -184,7 +184,7 @@ class A(A0): pass
184184
T = TypeVar('T', bound=A)
185185
def f(x: T) -> int:
186186
return x.foo(22)
187-
[builtins fixtures/staticmethod.py]
187+
[builtins fixtures/staticmethod.pyi]
188188

189189

190190
[case testBoundOnDecorator]
@@ -205,4 +205,4 @@ a = 1
205205
b = foo(a)
206206
b = 'a' # E: Incompatible types in assignment (expression has type "str", variable has type "int")
207207
twice(a) # E: Type argument 1 of "twice" has incompatible value "int"
208-
[builtins fixtures/args.py]
208+
[builtins fixtures/args.pyi]

0 commit comments

Comments
 (0)