Skip to content

Commit

Permalink
V0.7.2 - Python3.9 Support (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
hakancelikdev authored Jan 30, 2021
1 parent 17ac654 commit a11db72
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 25 deletions.
5 changes: 1 addition & 4 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ coverage:
patch: yes
changes: yes

comment:
layout: "reach, diff, files"
behavior: default
require_changes: no
comment: false

ignore:
- "setup.py"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/[email protected]

Expand All @@ -20,7 +20,7 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
python -m pip install pytest==6.1.1 pytest-cov==2.10.1
python -m pip install pytest==6.2.2 pytest-cov==2.11.1
- name: Test with pytest
run: |
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [0.7.2] - 31/January/2021

- [Python3.9 Support](https://github.com/hakancelik96/unimport/pull/166)

## [0.7.1] - 1/January/2021/

- [Fix by @hakancelik96 #127](https://github.com/hakancelik96/unimport/pull/161)
Expand Down
2 changes: 1 addition & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- _coverpage.md -->

# ![logo](_media/icon.png ":size=30%") <small>0.7.1</small>
# ![logo](_media/icon.png ":size=30%") <small>0.7.2</small>

> A linter, formatter for finding and removing unused import statements.
Expand Down
12 changes: 6 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
importlib_metadata==2.0.0
libcst==0.3.13
pathspec==0.8.0
pytest
pytest-cov
importlib_metadata==3.4.0
libcst==0.3.16
pathspec==0.8.1
pytest==6.2.2
pytest-cov==2.11.1
semantic-version==2.8.5
toml==0.10.1
toml==0.10.2
13 changes: 7 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import unimport.constants as C

assert sys.version_info >= (3, 6, 0), "unimport requires Python 3.6+"
assert sys.version_info >= (3, 6), "unimport requires Python 3.6+"

CURRENT_DIR = Path(__file__).parent

Expand All @@ -32,13 +32,13 @@ def get_long_description():
},
license="MIT",
license_file="LICENSE",
python_requires=">=3.6.0",
python_requires=">=3.6",
packages=["unimport"],
install_requires=[
"libcst==0.3.13",
"pathspec==0.8.0",
"toml==0.10.1",
"importlib_metadata==2.0.0",
"libcst==0.3.16",
"pathspec==0.8.1",
"toml==0.10.2",
"importlib_metadata==3.4.0",
],
extras_require={},
zip_safe=False,
Expand All @@ -53,6 +53,7 @@ def get_long_description():
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
],
entry_points={"console_scripts": ["unimport = unimport.__main__:main"]},
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py36, py37, py38, pre-commit
envlist = py36, py37, py38, py39, pre-commit

[testenv]
deps = -rrequirements-dev.txt
Expand Down
3 changes: 2 additions & 1 deletion unimport/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
DESCRIPTION = (
"A linter, formatter for finding and removing unused import statements."
)
VERSION = "0.7.1"
VERSION = "0.7.2"

PY38_PLUS = sys.version_info >= (3, 8)
PY39_PLUS = sys.version_info >= (3, 9)

SUBSCRIPT_TYPE_VARIABLE = frozenset(
{
Expand Down
14 changes: 10 additions & 4 deletions unimport/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,19 @@ def visit_constant_str(node: Union[ast.Constant, ast.Str]) -> None:
isinstance(node.value, ast.Name)
and node.value.id in C.SUBSCRIPT_TYPE_VARIABLE
):
if isinstance(node.slice.value, ast.Tuple): # type: ignore
for elt in node.slice.value.elts: # type: ignore

if C.PY39_PLUS:
_slice = node.slice
else:
_slice = node.slice.value # type: ignore

if isinstance(_slice, ast.Tuple): # type: ignore
for elt in _slice.elts: # type: ignore
if isinstance(elt, (ast.Constant, ast.Str)):
visit_constant_str(elt)
else:
if isinstance(node.slice.value, (ast.Constant, ast.Str)): # type: ignore
visit_constant_str(node.slice.value) # type: ignore
if isinstance(_slice, (ast.Constant, ast.Str)): # type: ignore
visit_constant_str(_slice) # type: ignore

@recursive
def visit_Call(self, node: ast.Call) -> None:
Expand Down

0 comments on commit a11db72

Please sign in to comment.