diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bb490da6f..d41676523 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: [3.6, 3.7, 3.8, 3.9, "3.10"] + python-version: [3.7, 3.8, 3.9, "3.10"] parser: [pure, native] steps: - uses: actions/checkout@v1 diff --git a/README.rst b/README.rst index f5a09998a..710e22232 100644 --- a/README.rst +++ b/README.rst @@ -125,7 +125,7 @@ For a more detailed usage example, `see our documentation Installation ------------ -LibCST requires Python 3.6+ and can be easily installed using most common Python +LibCST requires Python 3.7+ and can be easily installed using most common Python packaging tools. We recommend installing the latest stable release from `PyPI `_ with pip: diff --git a/libcst/_type_enforce.py b/libcst/_type_enforce.py index 3eb72e774..b13c41de4 100644 --- a/libcst/_type_enforce.py +++ b/libcst/_type_enforce.py @@ -3,17 +3,19 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -from typing import Any, Iterable, Mapping, MutableMapping, MutableSequence, Tuple +from typing import ( + Any, + ForwardRef, + Iterable, + Mapping, + MutableMapping, + MutableSequence, + Tuple, +) from typing_extensions import Literal from typing_inspect import get_args, get_origin, is_classvar, is_typevar, is_union_type -try: # py37+ - from typing import ForwardRef -except ImportError: # py36 - # pyre-fixme[21]: Could not find name `_ForwardRef` in `typing` (stubbed). - from typing import _ForwardRef as ForwardRef - def is_value_of_type( # noqa: C901 "too complex" # pyre-fixme[2]: Parameter annotation cannot be `Any`. @@ -47,12 +49,8 @@ def is_value_of_type( # noqa: C901 "too complex" - Type[...] """ if is_classvar(expected_type): - # `ClassVar` (no subscript) is implicitly `ClassVar[Any]` - if hasattr(expected_type, "__type__"): # py36 - expected_type = expected_type.__type__ or Any - else: # py37+ - classvar_args = get_args(expected_type) - expected_type = (classvar_args[0] or Any) if classvar_args else Any + classvar_args = get_args(expected_type) + expected_type = (classvar_args[0] or Any) if classvar_args else Any if is_typevar(expected_type): # treat this the same as Any @@ -70,10 +68,7 @@ def is_value_of_type( # noqa: C901 "too complex" ) elif isinstance(expected_origin_type, type(Literal)): - if hasattr(expected_type, "__values__"): # py36 - literal_values = expected_type.__values__ - else: # py37+ - literal_values = get_args(expected_type, evaluate=True) + literal_values = get_args(expected_type, evaluate=True) return any(value == literal for literal in literal_values) elif isinstance(expected_origin_type, ForwardRef): diff --git a/pyproject.toml b/pyproject.toml index 84cfc6282..986a2339d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,4 +9,4 @@ excludes = ["native/", "stubs/"] exclude-modules = '^libcst\.(testing|tests)' [build-system] -requires = ["setuptools", "wheel", "setuptools-rust"] \ No newline at end of file +requires = ["setuptools", "wheel", "setuptools-rust"] diff --git a/setup.py b/setup.py index 0418cf262..4fa892ddf 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ def no_local_scheme(version: str) -> str: ), }, name="libcst", - description="A concrete syntax tree with AST-like properties for Python 3.5, 3.6, 3.7 and 3.8 programs.", + description="A concrete syntax tree with AST-like properties for Python 3.5, 3.6, 3.7, 3.8, 3.9, and 3.10 programs.", long_description=long_description, long_description_content_type="text/x-rst", url="https://github.com/Instagram/LibCST", @@ -42,7 +42,7 @@ def no_local_scheme(version: str) -> str: "libcst.codemod.tests": ["*"], }, test_suite="libcst", - python_requires=">=3.6", + python_requires=">=3.7", setup_requires=["setuptools_scm"], install_requires=[dep.strip() for dep in open("requirements.txt").readlines()], extras_require={ @@ -62,9 +62,10 @@ def no_local_scheme(version: str) -> str: classifiers=[ "License :: OSI Approved :: MIT License", "Topic :: Software Development :: Libraries", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", ], zip_safe=False, # for mypy compatibility https://mypy.readthedocs.io/en/latest/installed_packages.html )