Skip to content
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

Drop support for running with 3.4 #6592

Merged
merged 4 commits into from Mar 27, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions mypy/dmypy.py
Expand Up @@ -18,6 +18,7 @@
from mypy.dmypy_util import DEFAULT_STATUS_FILE, receive
from mypy.ipc import IPCClient, IPCException
from mypy.dmypy_os import alive, kill
from mypy.util import check_python_version

from mypy.version import __version__

Expand Down Expand Up @@ -131,6 +132,7 @@ class BadStatus(Exception):

def main(argv: List[str]) -> None:
"""The code is top-down."""
check_python_version('dmypy')
args = parser.parse_args(argv)
if not args.action:
parser.print_usage()
Expand Down
24 changes: 10 additions & 14 deletions mypy/fastparse.py
Expand Up @@ -98,21 +98,17 @@ def ast3_parse(source: Union[str, bytes], filename: str, mode: str,
NamedExpr = Any
Constant = Any
except ImportError:
if sys.version_info.minor > 4:
try:
from typed_ast import ast35 # type: ignore
except ImportError:
print('The typed_ast package is not installed.\n'
'You can install it with `python3 -m pip install typed-ast`.',
file=sys.stderr)
else:
print('You need a more recent version of the typed_ast package.\n'
'You can update to the latest version with '
'`python3 -m pip install -U typed-ast`.',
file=sys.stderr)
try:
from typed_ast import ast35 # type: ignore
except ImportError:
print('The typed_ast package is not installed.\n'
'You can install it with `python3 -m pip install typed-ast`.',
file=sys.stderr)
else:
print('Mypy requires the typed_ast package, which is only compatible with\n'
'Python 3.5 and greater.', file=sys.stderr)
print('You need a more recent version of the typed_ast package.\n'
'You can update to the latest version with '
'`python3 -m pip install -U typed-ast`.',
file=sys.stderr)
sys.exit(1)

N = TypeVar('N', bound=Node)
Expand Down
24 changes: 10 additions & 14 deletions mypy/fastparse2.py
Expand Up @@ -60,21 +60,17 @@
# Import ast3 from fastparse, which has special case for Python 3.8
from mypy.fastparse import ast3, ast3_parse
except ImportError:
if sys.version_info.minor > 4:
try:
from typed_ast import ast35 # type: ignore
except ImportError:
print('The typed_ast package is not installed.\n'
'You can install it with `python3 -m pip install typed-ast`.',
file=sys.stderr)
else:
print('You need a more recent version of the typed_ast package.\n'
'You can update to the latest version with '
'`python3 -m pip install -U typed-ast`.',
file=sys.stderr)
try:
from typed_ast import ast35 # type: ignore
except ImportError:
print('The typed_ast package is not installed.\n'
'You can install it with `python3 -m pip install typed-ast`.',
file=sys.stderr)
else:
print('Mypy requires the typed_ast package, which is only compatible with\n'
'Python 3.5 and greater.', file=sys.stderr)
print('You need a more recent version of the typed_ast package.\n'
'You can update to the latest version with '
'`python3 -m pip install -U typed-ast`.',
file=sys.stderr)
sys.exit(1)

N = TypeVar('N', bound=Node)
Expand Down
9 changes: 1 addition & 8 deletions mypy/main.py
Expand Up @@ -53,14 +53,7 @@ def main(script_path: Optional[str], args: Optional[List[str]] = None) -> None:
args: Custom command-line arguments. If not given, sys.argv[1:] will
be used.
"""
# Check for known bad Python versions.
if sys.version_info[:2] < (3, 5):
sys.exit("Running mypy with Python 3.4 or lower is not supported; "
"please upgrade to 3.5 or newer")
if sys.version_info[:3] == (3, 5, 0):
sys.exit("Running mypy with Python 3.5.0 is not supported; "
"please upgrade to 3.5.1 or newer")

util.check_python_version('mypy')
t0 = time.time()
# To log stat() calls: os.stat = stat_proxy
sys.setrecursionlimit(2 ** 14)
Expand Down
1 change: 1 addition & 0 deletions mypy/stubgen.py
Expand Up @@ -1181,6 +1181,7 @@ def parse_options(args: List[str]) -> Options:


def main() -> None:
mypy.util.check_python_version('stubgen')
# Make sure that the current directory is in sys.path so that
# stubgen can be run on packages in the current directory.
if not ('' in sys.path or '.' in sys.path):
Expand Down
12 changes: 12 additions & 0 deletions mypy/util.py
Expand Up @@ -257,3 +257,15 @@ def hard_exit(status: int = 0) -> None:
def unmangle(name: str) -> str:
"""Remove internal suffixes from a short name."""
return name.rstrip("'")


def check_python_version(program: str) -> None:
"""Report issues with the Python used to run mypy, dmypy, or stubgen"""
# Check for known bad Python versions.
if sys.version_info[:2] < (3, 5):
sys.exit("Running {name} with Python 3.4 or lower is not supported; "
"please upgrade to 3.5 or newer".format(name=program))
# this can be deleted once we drop support for 3.5
if sys.version_info[:3] == (3, 5, 0):
sys.exit("Running stubgen with Python 3.5.0 is not supported; "
ethanhs marked this conversation as resolved.
Show resolved Hide resolved
"please upgrade to 3.5.1 or newer")
3 changes: 1 addition & 2 deletions tox.ini
@@ -1,8 +1,7 @@
[tox]
minversion = 3.5.1
skip_missing_interpreters = true
envlist = py34,
py35,
envlist = py35,
py36,
py37,
lint,
Expand Down