Skip to content

Commit

Permalink
refactor: use all ruff rules
Browse files Browse the repository at this point in the history
  • Loading branch information
leifwar committed Jan 11, 2025
1 parent 2c9d445 commit df68c96
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
rev: v0.8.6
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
59 changes: 7 additions & 52 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,60 +39,11 @@ target-version = "py311"
line-length = 120

[tool.ruff.lint]
select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"C90", # mccabe
"COM", # flake8-commas
"D", # pydocstyle
"DTZ", # flake8-datetimez
"E", "W", # pycodestyle
"ERA", # eradicate
"F", # Pyflakes
"FA",
"FBT", # boolean trap
"FIX", # fix me
"FLY", # flynt
"FURB", # refurb
"G", # flake8-logging-format
"I", # isort
"ICN", # import conventions
"INP", # no pep420
"INT", # gettext
"ISC", # implicit str concat
"LOG", # flake8-logging
"N", # pep8-nameing
"NPY", # numpy specific rules
"PD", # pandas vet
"PERF", # Perflint
"PGH",
"PIE", # flake8-pie
"PL", # pylint
"PT", # pytest style
"PTH", # Pathlib
"Q", # quotes
"RET", # Return
"RSE", # raise
"RUF", # Ruff specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLF", # Self
"SLOT",
"T10", # debug statements
"T20", # flake8-print
"TC", # Type checking
"TCH", # flake8-type-checking
"TID", # tidy import
"TRY", # tryceratops
"UP", # pyupgrade
"YTT", # flake8-2020
]
select = ["ALL"]

ignore = [
'ANN401',
'BLE001',
'COM812',
'D101',
'D102',
Expand All @@ -102,15 +53,19 @@ ignore = [
'D203',
'D213',
'D413',
'EM101',
'EM102',
'FBT001',
'FBT002',
'FIX002',
'S101',
'TD002',
'TD003',
'TRY003'
]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
fixable = ["ALL"]
unfixable = []

# Exclude a variety of commonly ignored directories.
Expand Down
8 changes: 5 additions & 3 deletions src/cimsparql/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from collections import defaultdict
from dataclasses import dataclass, field
from functools import cached_property
from typing import TYPE_CHECKING, ParamSpec, TypeVar
from typing import TYPE_CHECKING, ParamSpec, Self, TypeVar
from uuid import uuid4

import pandas as pd
Expand Down Expand Up @@ -117,13 +117,15 @@ def get_client(self, query_name: str) -> GraphDBClient:
"""
return self.clients[query_name]

def __enter__(self) -> Model:
def __enter__(self) -> Self:
transaction_id = str(uuid4())
for client in self.clients.values():
client.add_correlation_id_to_header(transaction_id)
return self

def __exit__(self, exc_type: type[BaseException], exc: BaseException, exc_tb: TracebackType) -> None:
def __exit__(
self, exc_type: type[BaseException] | None, exc: BaseException | None, exc_tb: TracebackType | None
) -> None:
_, _, _ = exc_type, exc, exc_tb
for client in self.clients.values():
client.clear_correlation_id_from_header()
Expand Down

0 comments on commit df68c96

Please sign in to comment.