From 00d12b6149942da98556a866d28c8b44918a9252 Mon Sep 17 00:00:00 2001 From: Stephen Liu Date: Fri, 21 Jun 2024 21:47:55 -0400 Subject: [PATCH 1/8] deprecate older pythons and fix up some configs --- .flake8 | 4 +++- .travis.yml | 1 - fourmat/assets/pyproject.toml | 2 +- fourmat/lint.py | 1 + pyproject.toml | 2 +- setup.py | 6 +++--- tox.ini | 2 +- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.flake8 b/.flake8 index 043e7a0..c2399d7 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,7 @@ [flake8] -ignore = E,W503 # Let Black handle all the formatting. +ignore = + # Let Black handle all the formatting. + E,W503 exclude = tests/snapshots, .svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg diff --git a/.travis.yml b/.travis.yml index 3278434..8178672 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ jobs: - { python: "3.12", env: "TOXENV=py312" } - { python: "3.11", env: "TOXENV=py311" } - { python: "3.10", env: "TOXENV=py310" } - - { python: "3.9", env: "TOXENV=py39" } - stage: Release if: tag IS present diff --git a/fourmat/assets/pyproject.toml b/fourmat/assets/pyproject.toml index 7e035cc..3ac094e 100644 --- a/fourmat/assets/pyproject.toml +++ b/fourmat/assets/pyproject.toml @@ -1,6 +1,6 @@ [tool.black] line-length = 79 -target-version = ['py36', 'py37', 'py38', 'py39', 'py310'] +target-version = ['py310', 'py311', 'py312'] [tool.isort] profile = "black" diff --git a/fourmat/lint.py b/fourmat/lint.py index ceaaf25..d385ccb 100644 --- a/fourmat/lint.py +++ b/fourmat/lint.py @@ -16,6 +16,7 @@ CONFIGURATION_FILES = (".flake8", "pyproject.toml") + # ----------------------------------------------------------------------------- class PathContext: def __init__(self, path): diff --git a/pyproject.toml b/pyproject.toml index e3b5e4b..3ac094e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.black] line-length = 79 -target-version = ['py39', 'py310', 'py311', 'py312'] +target-version = ['py310', 'py311', 'py312'] [tool.isort] profile = "black" diff --git a/setup.py b/setup.py index c89f222..b24bbdf 100644 --- a/setup.py +++ b/setup.py @@ -8,13 +8,12 @@ author="Giacomo Tagliabue", author_email="giacomo@gmail.com", license="MIT", - python_requires=">=3.9", + python_requires=">=3.10", classifiers=[ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", @@ -22,13 +21,14 @@ ], keywords="lint autoformat black flake8 isort", packages=find_packages(), - package_data={"fourmat": ("assets/*.*", "assets/.*")}, + package_data={"fourmat": ["assets/*.*", "assets/.*"]}, install_requires=( "click>=8", "black==24.3.0", "flake8-bugbear>=24,<25", "flake8>=7,<8", "isort>=5,<6", + "setuptools>=70", ), entry_points={"console_scripts": ("fourmat = fourmat:cli",)}, ) diff --git a/tox.ini b/tox.ini index cf49258..224df19 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py{36,37,38,39,310} +envlist = py{310,311,312} [testenv] usedevelop = True From 87e8249f4920f22308edc6ed6018ead87b2bc5ca Mon Sep 17 00:00:00 2001 From: Stephen Liu Date: Sat, 22 Jun 2024 16:29:40 -0400 Subject: [PATCH 2/8] migrate travis ci workflow to github actions --- .github/workflows/ci.yaml | 62 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..d596587 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,62 @@ +name: CI + +on: + push: + branches: + - main + tags: + - "v*.*.*" + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12"] + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools tox + + - name: Run tox + run: tox + + deploy: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.11 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build setuptools twine wheel + + - name: Build package + run: | + python -m build + + - name: Publish package to PyPI + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python -m twine upload dist/* From e036c97b7fdbb08083a140bcee21b33154556316 Mon Sep 17 00:00:00 2001 From: Stephen Liu Date: Sat, 22 Jun 2024 16:32:54 -0400 Subject: [PATCH 3/8] mainline branch is still called master --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d596587..5f0d95b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,12 +3,12 @@ name: CI on: push: branches: - - main + - master tags: - "v*.*.*" pull_request: branches: - - main + - master jobs: test: From 43f232b324bf089a5df4ee4caa8df85643d9c59d Mon Sep 17 00:00:00 2001 From: Stephen Liu Date: Sat, 22 Jun 2024 16:44:58 -0400 Subject: [PATCH 4/8] use TOKEN for clarity --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5f0d95b..70b9b86 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -57,6 +57,6 @@ jobs: - name: Publish package to PyPI env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | python -m twine upload dist/* From b19d37a65e5c8c50e65313310550d6dcf317044d Mon Sep 17 00:00:00 2001 From: Stephen Liu Date: Fri, 5 Sep 2025 17:47:23 -0400 Subject: [PATCH 5/8] modernize deprecated usage of pkg_resources --- fourmat/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fourmat/__init__.py b/fourmat/__init__.py index fc16b68..987a688 100644 --- a/fourmat/__init__.py +++ b/fourmat/__init__.py @@ -1,15 +1,15 @@ +from importlib.metadata import PackageNotFoundError, version from pathlib import Path import click -from pkg_resources import DistributionNotFound, get_distribution # ----------------------------------------------------------------------------- + try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: - # package is not installed - pass + __version__ = version(__name__) +except PackageNotFoundError: + raise RuntimeError(f"Package '{__name__}' is not installed.") # ----------------------------------------------------------------------------- From acf19b56b54f454702e30dead56d8b838b44bf30 Mon Sep 17 00:00:00 2001 From: Stephen Liu Date: Fri, 5 Sep 2025 17:50:24 -0400 Subject: [PATCH 6/8] update deps --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index b24bbdf..364167b 100644 --- a/setup.py +++ b/setup.py @@ -24,11 +24,11 @@ package_data={"fourmat": ["assets/*.*", "assets/.*"]}, install_requires=( "click>=8", - "black==24.3.0", + "black==25.1.0", "flake8-bugbear>=24,<25", "flake8>=7,<8", - "isort>=5,<6", - "setuptools>=70", + "isort>=6,<7", + "setuptools>=80", ), entry_points={"console_scripts": ("fourmat = fourmat:cli",)}, ) From 517f28b3f371885e5197c4a67c62905cc9c00587 Mon Sep 17 00:00:00 2001 From: Stephen Liu Date: Fri, 5 Sep 2025 17:52:12 -0400 Subject: [PATCH 7/8] bump version due to python 3.9 removal --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 364167b..6e5a417 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="fourmat", - version="1.0.0", + version="2.0.0", description="A library for batteries-included linting and autoformatting", url="https://github.com/4Catalyzer/fourmat", author="Giacomo Tagliabue", From cdc4ef5c4fd802195a84f5aa523b149b4689a2f1 Mon Sep 17 00:00:00 2001 From: Stephen Liu Date: Tue, 9 Sep 2025 12:45:24 -0400 Subject: [PATCH 8/8] use prior logic --- fourmat/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fourmat/__init__.py b/fourmat/__init__.py index 987a688..8f544f0 100644 --- a/fourmat/__init__.py +++ b/fourmat/__init__.py @@ -9,7 +9,8 @@ try: __version__ = version(__name__) except PackageNotFoundError: - raise RuntimeError(f"Package '{__name__}' is not installed.") + # package is not installed + pass # -----------------------------------------------------------------------------