8000 Bump `PYTHON3_VERSION_MIN` to `3.7` by sobolevn · Pull Request #15668 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Bump PYTHON3_VERSION_MIN to 3.7 #15668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix CI
  • Loading branch information
sobolevn committed Jul 14, 2023
commit 3c629f4bc8927adbc8f9d46ee9fdc4450bfbafe4
19 changes: 5 additions & 14 deletions test-data/unit/check-async-await.test
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,10 @@ class asyncify(Generic[T], AsyncIterator[T]):
raise StopAsyncIteration

async def wrong_iterable(obj: Iterable[int]):
[i async for i in obj]
[i for i in asyncify(obj)]
{i: i async for i in obj}
{i: i for i in asyncify(obj)}

[out]
main:18: error: "Iterable[int]" has no attribute "__aiter__" (not async iterable)
main:19: error: "asyncify[int]" has no attribute "__iter__"; maybe "__aiter__"? (not iterable)
main:20: error: "Iterable[int]" has no attribute "__aiter__" (not async iterable)
main:21: error: "asyncify[int]" has no attribute "__iter__"; maybe "__aiter__"? (not iterable)
[i async for i in obj] # E: "Iterable[int]" has no attribute "__aiter__" (not async iterable)
[i for i in asyncify(obj)] # E: "asyncify[int]" has no attribute "__iter__"; maybe "__aiter__"? (not iterable)
{i: i async for i in obj} # E: "Iterable[int]" has no attribute "__aiter__" (not async iterable)
{i: i for i in asyncify(obj)} # E: "asyncify[int]" has no attribute "__iter__"; maybe "__aiter__"? (not iterable)
[builtins fixtures/async_await.pyi]
[typing fixtures/typing-async.pyi]

Expand Down Expand Up @@ -513,15 +507,12 @@ async def gen() -> AsyncGenerator[int, None]:
yield i

def h() -> None:
for i in gen():
for i in gen(): # E: "AsyncGenerator[int, None]" has no attribute "__iter__"; maybe "__aiter__"? (not iterable)
pass

[builtins fixtures/dict.pyi]
[typing fixtures/typing-async.pyi]

[out]
main:9: error: "AsyncGenerator[int, None]" has no attribute "__iter__"; maybe "__aiter__"? (not iterable)

[case testAsyncGeneratorNoYieldFrom]
from typing import AsyncGenerator

Expand Down
16 changes: 4 additions & 12 deletions test-data/unit/check-class-namedtuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -354,16 +354,10 @@ import typing

class X(typing.NamedTuple):
x: int
y = 1
x.x: int
y = 1 # E: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]"
x.x: int # E: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]"
z: str = 'z'
aa: int

[out]
main:6: error: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]"
main:7: error: Invalid statement in NamedTuple definition; expected "field_name: field_type [= default]"
main:9: error: Non-default NamedTuple fields cannot follow default fields

aa: int # E: Non-default NamedTuple fields cannot follow default fields
[builtins fixtures/list.pyi]

[case testNewNamedTupleWithoutTypesSpecified]
Expand All @@ -382,10 +376,8 @@ class N(NamedTuple):
y: str

def f(a: Type[N]):
a()
a() # E: Missing positional arguments "x", "y" in call to "N"
[builtins fixtures/list.pyi]
[out] 8000
main:9: error: Missing positional arguments "x", "y" in call to "N"

[case testNewNamedTupleWithDefaults]
from typing import List, NamedTuple, Optional
Expand Down
19 changes: 0 additions & 19 deletions test-data/unit/check-modules.test
Original file line number Diff line number Diff line change
Expand Up @@ -2067,15 +2067,6 @@ def __getattr__(name): ...

[builtins fixtures/module.pyi]

[case testModuleLevelGetattrNotStub36]
import has_getattr
reveal_type(has_getattr.any_attribute) # E: Module has no attribute "any_attribute" \
# N: Revealed type is "Any"
[file has_getattr.py]
def __getattr__(name) -> str: ...

[builtins fixtures/module.pyi]

[case testModuleLevelGetattrNotStub37]
# flags: --python-version 3.7

Expand Down Expand Up @@ -2110,16 +2101,6 @@ def __getattr__(name: str) -> int: ...

[builtins fixtures/module.pyi]

[case testModuleLevelGetattrImportFromNotStub36]
from non_stub import name # E: Module "non_stub" has no attribute "name"
reveal_type(name) # N: Revealed type is "Any"

[file non_stub.py]
from typing import Any
def __getattr__(name: str) -> Any: ...

[builtins fixtures/module.pyi]

[case testModuleLevelGetattrImportFromNotStub37]
# flags: --python-version 3.7
from non_stub import name
Expand Down
11 changes: 0 additions & 11 deletions test-data/unit/check-newsemanal.test
Original file line number Diff line number Diff line change
Expand Up @@ -2571,17 +2571,6 @@ import n
[file n.pyi]
class C: pass

[case testNewAnalyzerModuleGetAttrInPython36Plus]
import m
import n

x: m.n.C # E: Name "m.n.C" is not defined
y: n.D # E: Name "n.D" is not defined
[file m.py]
import n
[file n.py]
def __getattr__(x): pass

[case testNewAnalyzerModuleGetAttrInPython37]
# flags: --python-version 3.7
import m
Expand Down
12 changes: 6 additions & 6 deletions test-data/unit/check-newsyntax.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ a = 5 # E: Incompatible types in assignment (expression has type "int", variabl
b: str = 5 # E: Incompatible types in assignment (expression has type "int", variable has type "str")

zzz: int
zzz: str # E: Name "zzz" already defined on line 10
zzz: str # E: Name "zzz" already defined on line 9
[out]

[case testNewSyntaxWithDict]
Expand Down Expand Up @@ -84,10 +84,10 @@ class X:
x.x: int

[out]
main:4: error: Unexpected type declaration
main:4: error: Unsupported target for indexed assignment ("str")
main:5: error: Type cannot be declared in assignment to non-self attribute
main:5: error: "str" has no attribute "x"
main:3: error: Unexpected type declaration
main:3: error: Unsupported target for indexed assignment ("str")
main:4: error: Type cannot be declared in assignment to non-self attribute
main:4: error: "str" has no attribute "x"

[case testNewSyntaxFStringBasics]
f'foobar'
Expand All @@ -110,8 +110,8 @@ f'{1 + ""}'
f'.{1 + ""}'
[builtins fixtures/f_string.pyi]
[out]
main:1: error: Unsupported operand types for + ("int" and "str")
main:2: error: Unsupported operand types for + ("int" and "str")
main:3: error: Unsupported operand types for + ("int" and "str")

[case testNewSyntaxFStringParseFormatOptions]
value = 10.5142
Expand Down
12 changes: 5 additions & 7 deletions test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ mypy.ini: [mypy]: ignore_missing_imports: Not a boolean: nah
[file mypy.ini]
\[mypy]
\[mypy-*]
python_version = 3.4
python_version = 3.11
[out]
mypy.ini: [mypy-*]: Per-module sections should only specify per-module flags (python_version)
== Return code: 0
Expand Down Expand Up @@ -633,18 +633,18 @@ usage: mypy [-h] [-v] [-V] [more options; see below]
mypy: error: Mypy no longer supports checking Python 2 code. Consider pinning to mypy<0.980 if you need to check Python 2 code.
== Return code: 2

[case testPythonVersionAccepted34]
[case testPythonVersionAccepted37]
# cmd: mypy -c pass
[file mypy.ini]
\[mypy]
python_version = 3.4
python_version = 3.7
[out]

[case testPythonVersionAccepted36]
[case testPythonVersionAccepted311]
# cmd: mypy -c pass
[file mypy.ini]
\[mypy]
python_version = 3.6
python_version = 3.11
[out]

-- This should be a dumping ground for tests of plugins that are sensitive to
Expand Down Expand Up @@ -679,8 +679,6 @@ int_pow.py:11: note: Revealed type is "Any"
[case testDisallowAnyGenericsBuiltinCollections]
# cmd: mypy m.py
[file mypy.ini]
\[mypy]
python_version=3.6
\[mypy-m]
disallow_any_generics = True

Expand Down
14 changes: 7 additions & 7 deletions test-data/unit/daemon.test
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ $ dmypy stop
Daemon stopped

[case testDaemonWarningSuccessExitCode-posix]
$ dmypy run -- foo.py --follow-imports=error
$ dmypy run -- foo.py --follow-imports=error --python-version=3.11
Daemon started
foo.py:2: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs
Success: no issues found in 1 source file
Expand All @@ -282,25 +282,25 @@ def foo():
[case testDaemonQuickstart]
$ {python} -c "print('x=1')" >foo.py
$ {python} -c "print('x=1')" >bar.py
$ mypy --local-partial-types --cache-fine-grained --follow-imports=error --no-sqlite-cache -- foo.py bar.py
$ mypy --local-partial-types --cache-fine-grained --follow-imports=error --no-sqlite-cache --python-version=3.11 -- foo.py bar.py
Success: no issues found in 2 source files
$ {python} -c "import shutil; shutil.copy('.mypy_cache/3.6/bar.meta.json', 'asdf.json')"
$ {python} -c "import shutil; shutil.copy('.mypy_cache/3.11/bar.meta.json', 'asdf.json')"
-- update bar's timestamp but don't change the file
$ {python} -c "import time;time.sleep(1)"
$ {python} -c "print('x=1')" >bar.py
$ dmypy run -- foo.py bar.py --follow-imports=error --use-fine-grained-cache --no-sqlite-cache
$ dmypy run -- foo.py bar.py --follow-imports=error --use-fine-grained-cache --no-sqlite-cache --python-version=3.11
Daemon started
Success: no issues found in 2 source files
$ dmypy status --fswatcher-dump-file test.json
Daemon is up and running
$ dmypy stop
Daemon stopped
-- copy the original bar cache file back so that the mtime mismatches
$ {python} -c "import shutil; shutil.copy('asdf.json', '.mypy_cache/3.6/bar.meta.json')"
$ {python} -c "import shutil; shutil.copy('asdf.json', '.mypy_cache/3.11/bar.meta.json')"
-- sleep guarantees timestamp changes
$ {python} -c "import time;time.sleep(1)"
$ {python} -c "print('lol')" >foo.py
$ dmypy run --log-file=log -- foo.py bar.py --follow-imports=error --use-fine-grained-cache --no-sqlite-cache --quickstart-file test.json
$ dmypy run --log-file=log -- foo.py bar.py --follow-imports=error --use-fine-grained-cache --no-sqlite-cache --python-version=3.11 --quickstart-file test.json
Daemon started
foo.py:1: error: Name "lol" is not defined
Found 1 error in 1 file (checked 2 source files)
Expand All @@ -309,7 +309,7 @@ Found 1 error in 1 file (checked 2 source files)
$ {python} -c "import sys; sys.stdout.write(open('log').read())"
-- make sure the meta file didn't get updated. we use this as an imperfect proxy for
-- whether the source file got rehashed, which we don't want it to have been.
$ {python} -c "x = open('.mypy_cache/3.6/bar.meta.json').read(); y = open('asdf.json').read(); assert x == y"
$ {python} -c "x = open('.mypy_cache/3.11/bar.meta.json').read(); y = open('asdf.json').read(); assert x == y"

[case testDaemonSuggest]
$ dmypy start --log-file log.txt -- --follow-imports=error --no-error-summary
Expand Down
8 changes: 1 addition & 7 deletions test-data/unit/parse-errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,7 @@ file:3: error: Syntax error in type comment
file:3: error: Inconsistent use of "*" in function signature
file:3: error: Inconsistent use of "**" in function signature

[case testPrintStatementInPython3]
print 1
[out]
file:2: error: Missing parentheses in call to 'print'

[case testPrintStatementInPython37]
# flags: --python-version 3.7
[case testPrintStatementInPython37Plus]
print 1
[out]
file:2: error: Missing parentheses in call to 'print'. Did you mean print(1)?
Expand Down
0