Skip to content

Commit

Permalink
pre-commit ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
FaydSpeare committed Aug 10, 2024
1 parent 4628985 commit cc4ad71
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 42 deletions.
75 changes: 38 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,38 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on: push
jobs:

build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Build a binary wheel and a source tarball
run: python3 -m build

- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
- build
runs-on: ubuntu-latest

environment:
Expand All @@ -43,34 +44,34 @@ jobs:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/ensembledata
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
hooks:
- id: ruff
# - id: ruff-format
2 changes: 1 addition & 1 deletion ensembledata/api/_requester.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import httpx

from ._response import EDResponse
from .errors import EDError
from ._version import version
from .errors import EDError

BASE_URL = "https://ensembledata.com/apis"
USER_AGENT = f"ensembledata-python/{version}"
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ Homepage = "https://ensembledata.com"
Documenation = "https://ensembledata.com/apis/docs"
Repository = "https://github.com/ensembledata/ensembledata-python"

[tool.mypy]
strict = true

[tool.ruff]
target-version = "py37"
line-length = 100
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ruff==0.5.6
ruff==0.5.7
mypy==1.11.1
pytest==7.4.4
pytest-asyncio=0.21.2
pytest-asyncio=0.21.2
pre-commit==2.21.0
Empty file added tests/__init__.py
Empty file.
6 changes: 4 additions & 2 deletions tests/test_clients.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import pytest

from ensembledata.api import EDClient, EDAsyncClient, EDError, errors
from ensembledata.api import EDAsyncClient, EDClient, EDError, errors


def test_client():
client = EDClient("xxx")

with pytest.raises(EDError) as e:
client.customer.get_usage("2024-01-01")

Expand All @@ -17,4 +19,4 @@ async def test_async_client():
with pytest.raises(EDError) as e:
await client.customer.get_usage("2024-01-01")

assert e.value.status_code == errors.STATUS_491_INVALID_TOKEN
assert e.value.status_code == errors.STATUS_491_INVALID_TOKEN

0 comments on commit cc4ad71

Please sign in to comment.