Skip to content

Commit

Permalink
change ruff settings and fix/format all files
Browse files Browse the repository at this point in the history
  • Loading branch information
se-jaeger committed Feb 27, 2024
1 parent 6407c95 commit 3b1f349
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 43 deletions.
20 changes: 13 additions & 7 deletions error_generation/api/low_level.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import math
import random
from dataclasses import dataclass, field
Expand All @@ -7,13 +9,12 @@

@dataclass
class Column:

"""Describe a column in a Dataframe."""

name: str = field(default=None)
index: int = field(default=None)
name: str | None = field(default=None)
index: int | None = field(default=None)

def __post_init__(self):
def __post_init__(self: Column) -> None:
if self.name is None and self.index is None:
msg = "Specify either column name or index."
raise ValueError(msg)
Expand All @@ -32,7 +33,12 @@ def error_function(x):


def create_errors(
table: pd.DataFrame, column: Column, error_rate: float, mechanism: Mechanism, error_type: ErrorType, condition_to_column: Column | None = None
table: pd.DataFrame,
column: Column,
error_rate: float,
mechanism: Mechanism,
error_type: ErrorType,
condition_to_column: Column | None = None,
) -> tuple[pd.DataFrame, pd.DataFrame]:
try:
series = table.loc[column.name]
Expand All @@ -43,8 +49,8 @@ def create_errors(
raise ValueError(msg) from None
n_rows = len(series)

# TODO: this should be its own function
print(f"And use {mechanism} and {error_type} and {condition_to_column} to infer " "error positions.")
# TODO(phju): this should be its own function
print(f"And use {mechanism} and {error_type} and {condition_to_column} to infer error positions.")
n_errors = math.floor(n_rows * error_rate)

error_rows = random.sample(n_rows, n_errors)
Expand Down
56 changes: 20 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,27 @@ ignore_missing_imports = true

[tool.ruff]
line-length = 160
lint.select = [
"ALL", # include all the rules, including new ones
target-version = "py39"
fix = true
extend-include = ["*.ipynb"]

[tool.ruff.lint]
select = [
"ALL", # Include all the rules, including new ones
]
ignore = [
"FIX", # Temporary developer notes should not break actions

"D100", # Do not document public modules
"D104", # Do not document public packages
"TD003", # Allow TODOs without links
"ISC003", # Do not implicietly concatenate strings
]
lint.ignore = [
#### modules
"ANN", # flake8-annotations
"COM", # flake8-commas
"C90", # mccabe complexity
"DJ", # django
"EXE", # flake8-executable
"T10", # debugger
"TID", # flake8-tidy-imports

#### specific rules
"D100", # ignore missing docs
"D101",
"D102",
"D103",
"D104",
"D105",
"D106",
"D107",
"D200",
"D205",
"D211", # no blank line before class
"D212",
"D400",
"D401",
"D415",
"E402", # false positives for local imports
"E501", # line too long
"TRY003", # external messages in exceptions are too verbose
"TD002",
"TD003",
"FIX002", # too verbose descriptions of todos
'PLR0913', # too many arguments in function definition
'T201', # allow print()
'ISC001',
[tool.ruff.lint.per-file-ignores]
"**/__init__.py" = [
"F401", # Unused imports in __init__ files can make sense
]

[tool.ruff.lint.pydocstyle]
convention = "google"

0 comments on commit 3b1f349

Please sign in to comment.