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

Use flake8-type-checking #317

Merged
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: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ max-line-length = 88
ignore = E501, E203, W503, ANN101, ANN102, SIM106
ban-relative-imports = True
mypy-init-return = True
enable-extensions = TC, TC1
type-checking-exempt-modules = typing, typing-extensions
format-greedy = 1
per-file-ignores =
__init__.py:F401
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ repos:
- flake8-eradicate==1.2.0
- flake8-simplify==0.15.1
- flake8-tidy-imports==4.6.0
- flake8-type-checking==1.3.3
- flake8-use-fstring==1.3

- repo: https://github.com/asottile/pyupgrade
Expand Down
3 changes: 2 additions & 1 deletion src/poetry/core/masonry/builder.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING


if TYPE_CHECKING:
from pathlib import Path

from poetry.core.poetry import Poetry


Expand Down
6 changes: 5 additions & 1 deletion src/poetry/core/masonry/utils/include.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING


if TYPE_CHECKING:
from pathlib import Path


class Include:
Expand Down
6 changes: 5 additions & 1 deletion src/poetry/core/masonry/utils/package_include.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING

from poetry.core.masonry.utils.include import Include


if TYPE_CHECKING:
from pathlib import Path


class PackageInclude(Include):
def __init__(
self,
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/core/packages/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
SUPPORTED_EXTENSIONS = ZIP_EXTENSIONS + TAR_EXTENSIONS

try:
import bz2 # noqa: F401
import bz2 # noqa: F401, TC002

SUPPORTED_EXTENSIONS += BZ2_EXTENSIONS
except ImportError:
pass

try:
# Only for Python 3.3+
import lzma # noqa: F401
import lzma # noqa: F401, TC002

SUPPORTED_EXTENSIONS += XZ_EXTENSIONS
except ImportError:
Expand Down
3 changes: 2 additions & 1 deletion src/poetry/core/pyproject/toml.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any


if TYPE_CHECKING:
from pathlib import Path

from tomlkit.container import Container
from tomlkit.items import Item
from tomlkit.toml_document import TOMLDocument
Expand Down
3 changes: 2 additions & 1 deletion src/poetry/core/version/parser.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any


if TYPE_CHECKING:
from pathlib import Path

from lark import Lark
from lark import Tree

Expand Down
2 changes: 1 addition & 1 deletion src/poetry/core/version/pep440/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from packaging.version import VERSION_PATTERN

from poetry.core.version.exceptions import InvalidVersion
from poetry.core.version.pep440 import LocalSegmentType
from poetry.core.version.pep440 import Release
from poetry.core.version.pep440 import ReleaseTag


if TYPE_CHECKING:
from poetry.core.version.pep440 import LocalSegmentType
from poetry.core.version.pep440.version import PEP440Version


Expand Down
6 changes: 5 additions & 1 deletion src/poetry/core/version/pep440/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
import dataclasses
import math

from typing import TYPE_CHECKING
from typing import Any
from typing import TypeVar

from poetry.core.version.pep440.segments import RELEASE_PHASE_ALPHA
from poetry.core.version.pep440.segments import RELEASE_PHASE_DEV
from poetry.core.version.pep440.segments import RELEASE_PHASE_POST
from poetry.core.version.pep440.segments import LocalSegmentType
from poetry.core.version.pep440.segments import Release
from poetry.core.version.pep440.segments import ReleaseTag


if TYPE_CHECKING:
from poetry.core.version.pep440.segments import LocalSegmentType


T = TypeVar("T", bound="PEP440Version")

# we use the phase "z" to ensure we always sort this after other phases
Expand Down
6 changes: 5 additions & 1 deletion tests/pyproject/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING

import pytest


if TYPE_CHECKING:
from pathlib import Path


@pytest.fixture
def pyproject_toml(tmp_path: Path) -> Path:
path = tmp_path / "pyproject.toml"
Expand Down