Skip to content

Commit

Permalink
Use ruff for pre-commit (#45)
Browse files Browse the repository at this point in the history
* Use ruff for pre-commit
* Drop .flake8 config
* Add ruff GitHub action
  • Loading branch information
bpepple authored Feb 6, 2024
1 parent b927d0f commit ccd22a5
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 358 deletions.
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

8 changes: 8 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Ruff
on: [ push, pull_request ]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
24 changes: 5 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,9 @@ repos:
rev: v2.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pycqa/isort
rev: 5.13.2
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.0
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: 24.1.1
hooks:
- id: black
language_version: python3.11
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
[flake8-docstrings, flake8-builtins, flake8-rst-docstrings]
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py36-plus", "--py37-plus", "--py38-plus", "--py39-plus"]
- id: ruff
- id: ruff-format
Empty file added docs/source/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import os
import sys

sys.path.insert(0, os.path.abspath("../.."))
sys.path.insert(0, os.path.abspath("../..")) # noqa: PTH100
# This import needs to be *after* setting the sys path
import mokkari # noqa #E402
import mokkari # E402

# -- Project information -----------------------------------------------------

Expand Down
7 changes: 3 additions & 4 deletions mokkari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
# Keep this at beginning of file to prevent circular import with session
__version__ = "3.0.0"

from typing import Optional

from mokkari import exceptions, session, sqlite_cache


def api(
username: Optional[str] = None,
passwd: Optional[str] = None,
username: str | None = None,
passwd: str | None = None,
cache: sqlite_cache.SqliteCache = None,
user_agent: Optional[str] = None,
user_agent: str | None = None,
) -> session.Session:
"""Entry function the sets login credentials for metron.cloud.
Expand Down
10 changes: 5 additions & 5 deletions mokkari/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
class ApiError(Exception):
"""Class for any api errors."""

def __init__(self, *args, **kwargs):
def __init__(self: "ApiError", *args: tuple[any], **kwargs: dict[str, any]) -> None:
"""Initialize an ApiError."""
Exception.__init__(self, *args, **kwargs)


class AuthenticationError(ApiError):
class AuthenticationError(Exception):
"""Class for any authentication errors."""

def __init__(self, *args, **kwargs):
def __init__(self: "AuthenticationError", *args: tuple[any], **kwargs: dict[str, any]) -> None:
"""Initialize an AuthenticationError."""
Exception.__init__(self, *args, **kwargs)


class CacheError(ApiError):
class CacheError(Exception):
"""Class for any database cache errors."""

def __init__(self, *args, **kwargs):
def __init__(self: "CacheError", *args: tuple[any], **kwargs: dict[str, any]) -> None:
"""Initialize an CacheError."""
Exception.__init__(self, *args, **kwargs)
1 change: 1 addition & 0 deletions mokkari/schemas/character.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: RUF012
"""
Character module.
Expand Down
1 change: 1 addition & 0 deletions mokkari/schemas/issue.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: RUF012
"""
Issue module.
Expand Down
1 change: 1 addition & 0 deletions mokkari/schemas/series.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: RUF012
"""
Series module.
Expand Down
1 change: 1 addition & 0 deletions mokkari/schemas/team.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: RUF012
"""
Team module.
Expand Down
Loading

0 comments on commit ccd22a5

Please sign in to comment.