Skip to content

Commit 514be93

Browse files
fix ruff issues
1 parent 9144ad7 commit 514be93

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ uv pip install -e .
3939

4040
The project uses `ruff` for both linting and formatting. Run the following command to check your code:
4141
```bash
42-
uv run ruff check
42+
uv run ruff format . --check --diff
4343
```
4444

4545
The project uses `pyright` for type checking. Run the following command to check your code:

src/examples/user.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def from_json(cls, json_str: str) -> "User": # noqa: D102
3535
logger.error(f"Conversion exception: {e.__class__.__name__}: {e!s}")
3636
raise
3737

38+
3839
# ruff: noqa
3940
def main() -> None:
4041
"""Show how to use the User class."""
@@ -51,5 +52,8 @@ def main() -> None:
5152
pass
5253

5354

55+
# ruff: enable
56+
57+
5458
if __name__ == "__main__":
5559
main()

src/logging_config.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
class RelativePathLogRecord(LogRecord):
2121
"""Extended LogRecord that adds a relpath attribute for relative paths."""
2222

23-
def __init__(self, *args, **kwargs) -> None: # noqa: D107 ANN002 ANN003
23+
def __init__(self, *args, **kwargs) -> None: # noqa: D107 ANN002 ANN003
2424
super().__init__(*args, **kwargs)
25-
workspace_path = os.getcwd() # noqa: PTH109
25+
workspace_path = os.getcwd() # noqa: PTH109
2626
try:
2727
# Convert pathname to a relative path from workspace root
2828
if hasattr(self, "pathname") and self.pathname.startswith(workspace_path):
@@ -36,23 +36,34 @@ def __init__(self, *args, **kwargs) -> None: # noqa: D107 ANN002 ANN003
3636
class RelativePathFilter(Filter):
3737
"""Filter that ensures the relpath attribute is available."""
3838

39-
def filter(self, record) -> bool: # noqa: D102 ARG002 ANN001
39+
def filter(self, record) -> bool: # noqa: D102 ARG002 ANN001
4040
return True
4141

4242

4343
class RelativePathLoggerFactory(getLoggerClass()):
4444
"""Custom logger class that uses RelativePathLogRecord."""
4545

46-
def makeRecord( # noqa: PLR0913 N802
46+
# ruff: noqa
47+
def makeRecord(
4748
self,
48-
name, level, fn, lno, msg, args, exc_info, # noqa: ANN001
49-
func=None, extra=None, sinfo=None, # noqa: ANN001 ARG002
49+
name,
50+
level,
51+
fn,
52+
lno,
53+
msg,
54+
args,
55+
exc_info,
56+
func=None,
57+
extra=None,
58+
sinfo=None,
5059
) -> RelativePathLogRecord:
5160
"""Create a RelativePathLogRecord."""
5261
return RelativePathLogRecord(
5362
name, level, fn, lno, msg, args, exc_info, func, sinfo
5463
)
5564

65+
# ruff: enable
66+
5667

5768
def setup_logging() -> None: # noqa: D103
5869
global logger_config_loaded # noqa: PLW0603

0 commit comments

Comments
 (0)