diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5827c6d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + + - package-ecosystem: pip + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..5b9104b --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,16 @@ +name: Auto-Release + +on: + push: + branches: + - main + +concurrency: + group: auto-release + cancel-in-progress: true + +jobs: + release: + permissions: + contents: write + uses: owenvoke/semantic-release-config/.github/workflows/release.yml@f7423f9436c60a35f74e54dedfa5f80f848a5a10 # v1.3.0 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8d69ab6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: Publish + +on: + release: + types: + - published + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + name: Publish to PyPI + steps: + + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + + - name: Setup Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: '3.11' + + - name: Install Hatch + run: python3 -m pip install hatch + + - name: Build package archive + run: hatch build + + - name: Publish to PyPI + run: hatch publish --user '__token__' --auth '${{ secrets.PYPI_API_TOKEN }}' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index db0d2f0..c26bad6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,36 +1,52 @@ name: Tests -on: [ push, pull_request ] +on: + push: + branches: + - main + pull_request: -jobs: - tests: - name: Tests +permissions: + contents: read +jobs: + style: runs-on: ubuntu-latest + name: Check style formatting + steps: + + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Setup Python + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version: '3.x' - env: - FORCE_COLOR: '1' + - name: Install Hatch + run: python3 -m pip install hatch + # Runs the Ruff version pinned in pyproject.toml, annotating PRs inline. + - name: Style Check + run: hatch run lint + env: + RUFF_OUTPUT_FORMAT: github + + tests: + runs-on: ubuntu-latest + name: Tests steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: - python-version: '3.10' + python-version: '3.11' - - name: Install Pip dependencies - run: pipx install hatch + - name: Install Hatch + run: python3 -m pip install hatch - - name: Run Tests + - name: Run tests run: hatch run test - - - name: Build package archive - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - run: hatch build - - - name: Publish to PyPi - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - run: hatch publish --user '__token__' --auth '${{ secrets.PYPI_API_TOKEN }}' diff --git a/README.md b/README.md index 5634fb3..f29fcf2 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ from ecologi import Ecologi ecologi = Ecologi() -sites = ecologi.impact('owenvoke') +sites = ecologi.impact("owenvoke") ``` | Available Methods | Description | diff --git a/ecologi/__init__.py b/ecologi/__init__.py index bbe02d0..70576ea 100644 --- a/ecologi/__init__.py +++ b/ecologi/__init__.py @@ -1,2 +1,4 @@ -from .ecologi import Ecologi, EcologiException, NotFoundException +from .ecologi import Ecologi as Ecologi +from .ecologi import EcologiException as EcologiException +from .ecologi import NotFoundException as NotFoundException from .types import * diff --git a/ecologi/ecologi.py b/ecologi/ecologi.py index d96faa2..1e7f487 100644 --- a/ecologi/ecologi.py +++ b/ecologi/ecologi.py @@ -1,4 +1,6 @@ -from typing import Optional, cast +from __future__ import annotations + +from typing import cast import requests @@ -35,7 +37,7 @@ def impact(self, username: str) -> Impact: def get(self, url: str): return self.__request("GET", url) - def __request(self, method: str, url: str, params: Optional[dict] = None): + def __request(self, method: str, url: str, params: dict | None = None): if params is None: params = {} diff --git a/pyproject.toml b/pyproject.toml index a39b0e3..e034860 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ classifiers = [ "Intended Audience :: Developers", "Programming Language :: Python :: 3 :: Only", ] -requires-python = ">=3.9.0" +requires-python = ">=3.11.0" dependencies = [ "requests>=2.28.1" ] @@ -41,22 +41,23 @@ packages = ["ecologi"] [tool.hatch.envs.default] dependencies = [ - "black", "mypy", "pytest==7.1", "requests-mock==1.10", + "ruff==0.17.1", "types-requests", ] [tool.hatch.envs.default.scripts] test = [ - "black --check --diff .", "mypy ecologi", "pytest", ] lint = [ - "black ." + "ruff format --check --diff .", + "ruff check .", +] +fix = [ + "ruff format .", + "ruff check --fix .", ] - -[tool.black] -target-version = ["py39", "py310"] diff --git a/tests/test_ecologi.py b/tests/test_ecologi.py index ab81577..03d23bc 100644 --- a/tests/test_ecologi.py +++ b/tests/test_ecologi.py @@ -1,4 +1,5 @@ import requests_mock + from ecologi import Ecologi ecologi = Ecologi()