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

Python3.10 support. #81

Merged
merged 15 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9, 3.10]
hadialqattan marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased]

### Added

- [Add support for Python 3.10](https://github.com/hadialqattan/pycln/pull/81)

### Fixed

- [Parsing local path import with null-pacakge causes AttributeError by @hadialqattan](https://github.com/hadialqattan/pycln/pull/76)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ classifiers = [
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Utilities"]
license = "MIT"
readme = "README.md"
Expand All @@ -22,7 +23,7 @@ include = ["pyproject.toml"]
pycln = "pycln.cli:app"

[tool.poetry.dependencies]
python = ">=3.6.2, <3.10"
python = ">=3.6.2, <3.11"
hadialqattan marked this conversation as resolved.
Show resolved Hide resolved
typer = "^0.3.1"
toml = "^0.10.1"
dataclasses = {version = "^0.7", python = "3.6"}
Expand Down
21 changes: 20 additions & 1 deletion tests/test_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Constants.
MOCK = "pycln.utils.scan.%s"
PY38_PLUS = sys.version_info >= (3, 8)
PY310_PLUS = sys.version_info >= (3, 10)


class TestDataclasses:
Expand Down Expand Up @@ -463,6 +464,24 @@ def test_visit_Expr(self, visit_Name, code, expec_names):
),
pytest.param("foobar: '' = 'x'\n", None, id="empty string annotation"),
pytest.param("foobar = 'x'\n", None, id="no string annotation"),
pytest.param(
("def foo(bar: str | int):\n" " pass\n"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the union type syntax is also available in Python 3.7+ if you add the line

from __future__ import annotations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

110K matches for this on public GH repos, and most of them are using from __future__ import annotations to enable the nicer syntax from newer Pythons.

{"str", "int"},
id="union types - arg",
marks=pytest.mark.skipif(
not PY310_PLUS,
reason="This feature is only available in Python >=3.10.",
),
),
pytest.param(
("def foo() -> str | int :\n" " pass\n"),
{"str", "int"},
id="union types - return",
marks=pytest.mark.skipif(
not PY310_PLUS,
reason="This feature is only available in Python >=3.10.",
),
),
],
)
@mock.patch(MOCK % "SourceAnalyzer.visit_Name")
Expand All @@ -473,7 +492,7 @@ def test_visit_string_type_annotation(self, visit_Name, code, expec_names):

@pytest.mark.skipif(
not PY38_PLUS,
reason="This feature is only available for Python >=3.8.",
reason="This feature is only available in Python >=3.8.",
)
@pytest.mark.parametrize(
"code, expec_names",
Expand Down