From 3391dd22689deb5116740b7cea6397e5309f4f1c Mon Sep 17 00:00:00 2001 From: Seth Morton Date: Tue, 8 Oct 2024 22:54:36 -0700 Subject: [PATCH] Fix issues around new _version.py file --- .github/workflows/code-quality.yml | 5 ++++- dev/clean.py | 2 +- natsort/__init__.py | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 754f731..e99cf00 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -55,7 +55,10 @@ jobs: python-version: '3.8' - name: Install MyPy - run: pip install mypy hypothesis pytest pytest-mock fastnumbers + run: pip install mypy hypothesis pytest pytest-mock fastnumbers setuptools_scm + + - name: Create _version.py file + run: python -m setuptools_scm --force-write-version-files - name: Run MyPy run: mypy --strict natsort tests diff --git a/dev/clean.py b/dev/clean.py index 2805014..5e6105d 100755 --- a/dev/clean.py +++ b/dev/clean.py @@ -38,4 +38,4 @@ # Remove _version.py version = pathlib.Path("natsort/_version.py") if version.is_file(): - f.unlink() + version.unlink() diff --git a/natsort/__init__.py b/natsort/__init__.py index b9a51e4..8f321cb 100644 --- a/natsort/__init__.py +++ b/natsort/__init__.py @@ -1,5 +1,7 @@ try: - from natsort._version import __version__, __version_tuple__ + # The redundant "as" tells mypy to treat as explict import + from natsort._version import __version__ as __version__ + from natsort._version import __version_tuple__ as __version_tuple__ except ImportError: __version__ = "unknown version" __version_tuple__ = (0, 0, "unknown version")