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 libcst using a python 3.6 interpreter #663

Merged
merged 2 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://pypi.org/project/libcst/>`_ with pip:

Expand Down
29 changes: 12 additions & 17 deletions libcst/_type_enforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ excludes = ["native/", "stubs/"]
exclude-modules = '^libcst\.(testing|tests)'

[build-system]
requires = ["setuptools", "wheel", "setuptools-rust"]
requires = ["setuptools", "wheel", "setuptools-rust"]
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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={
Expand All @@ -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
)