Skip to content

Commit

Permalink
chore: Add pre-commit
Browse files Browse the repository at this point in the history
closes #2
  • Loading branch information
alukach committed Aug 21, 2024
1 parent d90bd37 commit 2c65bb0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint

on:
push:
paths:
- "eoapi/**"

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"

- name: Install pre-commit
run: pip install -e ".[lint]"

- name: Run pre-commit
run: pre-commit run --all-files
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
language_version: python
args: ["-m", "3", "--trailing-comma", "-l", "88"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
language_version: python
additional_dependencies:
- types-requests
- types-attrs
- types-PyYAML
4 changes: 2 additions & 2 deletions eoapi/auth_utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import urllib.request
from dataclasses import dataclass, field
from typing import Annotated, Any, Callable, Dict, Optional, Sequence, TYPE_CHECKING
from typing import TYPE_CHECKING, Annotated, Any, Callable, Optional, Sequence

import jwt
from fastapi import HTTPException, Security, routing, security, status
Expand Down Expand Up @@ -55,7 +55,7 @@ def __post_init__(self):
)

@classmethod
def from_settings(cls, settings: 'OpenIdConnectSettings') -> 'OpenIdConnectAuth':
def from_settings(cls, settings: "OpenIdConnectSettings") -> "OpenIdConnectAuth":
return cls(**settings.model_dump(include=cls.__dataclass_fields__.keys()))

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion eoapi/auth_utils/errors.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
class OidcFetchError(Exception):
pass
pass
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ readme = "README.md"
requires-python = ">=3.8"

[project.optional-dependencies]
lint = [
"pre-commit",
]
testing = [
"pytest>=6.0",
"coverage",
Expand Down

0 comments on commit 2c65bb0

Please sign in to comment.