From deab08a223254b3c044a2e77c3cb7388d0c339f8 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 20 Jul 2023 00:09:49 -0400 Subject: [PATCH] fix: drop _compat pre-filled module --- {{cookiecutter.project_name}}/pyproject.toml | 8 +++--- .../_compat/__init__.py | 8 ------ .../_compat/typing.py | 26 ------------------- .../tests/test_package.py | 7 ----- 4 files changed, 3 insertions(+), 46 deletions(-) delete mode 100644 {{cookiecutter.project_name}}/src/{{cookiecutter.__project_slug}}/_compat/__init__.py delete mode 100644 {{cookiecutter.project_name}}/src/{{cookiecutter.__project_slug}}/_compat/typing.py diff --git a/{{cookiecutter.project_name}}/pyproject.toml b/{{cookiecutter.project_name}}/pyproject.toml index 441f1554..b5647631 100644 --- a/{{cookiecutter.project_name}}/pyproject.toml +++ b/{{cookiecutter.project_name}}/pyproject.toml @@ -91,7 +91,6 @@ classifiers = [ [tool.poetry.dependencies] python = ">=3.8" -typing_extensions = { version = ">=4.6", python = "<3.11" } furo = { version = ">=22", optional = true } myst_parser = { version = ">=0.13", optional = true } @@ -162,9 +161,7 @@ classifiers = [ {%- if cookiecutter.backend in ["trampolim", "flit", "hatch"] %} dynamic = ["version"] {%- endif %} -dependencies = [ - "typing_extensions >=4.6; python_version<'3.11'", -] +dependencies = [] [project.optional-dependencies] test = [ @@ -287,7 +284,6 @@ extend-ignore = [ {%- if cookiecutter.backend in ["setuptools", "pybind11", "poetry"] %} target-version = "py38" {%- endif %} -typing-modules = ["{{ cookiecutter.__project_slug }}._compat.typing"] src = ["src"] unfixable = [ "T20", # Removes print statements @@ -296,6 +292,8 @@ unfixable = [ exclude = [] flake8-unused-arguments.ignore-variadic-names = true isort.required-imports = ["from __future__ import annotations"] +# Uncomment if using a _compat.typing backport +# typing-modules = ["{{ cookiecutter.__project_slug }}._compat.typing"] [tool.ruff.per-file-ignores] "tests/**" = ["T20"] diff --git a/{{cookiecutter.project_name}}/src/{{cookiecutter.__project_slug}}/_compat/__init__.py b/{{cookiecutter.project_name}}/src/{{cookiecutter.__project_slug}}/_compat/__init__.py deleted file mode 100644 index e11aa6e9..00000000 --- a/{{cookiecutter.project_name}}/src/{{cookiecutter.__project_slug}}/_compat/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -""" -Copyright (c) {{ cookiecutter.__year }} {{ cookiecutter.full_name }}. All rights reserved. - -{{ cookiecutter.project_name }}: {{ cookiecutter.project_short_description }} -""" - - -from __future__ import annotations diff --git a/{{cookiecutter.project_name}}/src/{{cookiecutter.__project_slug}}/_compat/typing.py b/{{cookiecutter.project_name}}/src/{{cookiecutter.__project_slug}}/_compat/typing.py deleted file mode 100644 index eb10ca5c..00000000 --- a/{{cookiecutter.project_name}}/src/{{cookiecutter.__project_slug}}/_compat/typing.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -Copyright (c) {{ cookiecutter.__year }} {{ cookiecutter.full_name }}. All rights reserved. - -{{ cookiecutter.project_name }}: {{ cookiecutter.project_short_description }} -""" - - -from __future__ import annotations - -import sys - -if sys.version_info < (3, 10): - from typing_extensions import TypeAlias -else: - from typing import TypeAlias - -if sys.version_info < (3, 11): - from typing_extensions import Self, assert_never -else: - from typing import Self, assert_never - -__all__ = ["TypeAlias", "Self", "assert_never"] - - -def __dir__() -> list[str]: - return __all__ diff --git a/{{cookiecutter.project_name}}/tests/test_package.py b/{{cookiecutter.project_name}}/tests/test_package.py index b25ed516..357dce64 100644 --- a/{{cookiecutter.project_name}}/tests/test_package.py +++ b/{{cookiecutter.project_name}}/tests/test_package.py @@ -1,14 +1,7 @@ from __future__ import annotations import {{ cookiecutter.__project_slug }} as m -import {{ cookiecutter.__project_slug }}._compat.typing as typing_backports def test_version(): assert m.__version__ - - -def test_has_typing(): - assert hasattr(typing_backports, "TypeAlias") - assert hasattr(typing_backports, "Self") - assert hasattr(typing_backports, "assert_never")