Skip to content

Commit f34603e

Browse files
committed
Adding pre-commit ruff checks and doing lint fixes
1 parent c863685 commit f34603e

20 files changed

+280
-148
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
python-version: [ 3.9, 3.10, 3.11, 3.12, 3.12]
16+
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
1717

1818
steps:
1919
- uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v2.5.0
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
44
hooks:
55
- id: mixed-line-ending
66
- id: trailing-whitespace
@@ -9,8 +9,12 @@ repos:
99
- id: check-byte-order-marker
1010
- id: debug-statements
1111
- id: check-yaml
12-
- repo: https://github.com/ambv/black
13-
rev: 20.8b1
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
# Ruff version.
14+
rev: v0.12.1
1415
hooks:
15-
- id: black
16-
args: [--config=.black.toml]
16+
# Run the linter.
17+
- id: ruff-check
18+
args: [ --fix ]
19+
# Run the formatter.
20+
- id: ruff-format

Makefile

Lines changed: 0 additions & 87 deletions
This file was deleted.

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Homepage = "https://github.com/cdgriffith/Reusables"
4040

4141
[dependency-groups]
4242
dev = [
43+
"pre-commit>=3.5.0",
4344
"pytest>=8.3.5",
4445
"rarfile>=4.2",
4546
"ruff>=0.12.1",
@@ -117,3 +118,7 @@ docstring-code-format = true
117118
# This only has an effect when the `docstring-code-format` setting is
118119
# enabled.
119120
docstring-code-line-length = "dynamic"
121+
122+
123+
[tool.ruff.lint.per-file-ignores]
124+
"__init__.py" = ["F403"]

reusables/cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
import shutil
1313
from collections import deque
1414

15-
from reusables.shared_variables import *
15+
from reusables.shared_variables import win_based, python_version
1616
from reusables.process_helpers import run
17-
from reusables.shared_variables import win_based
1817
from reusables.file_operations import find_files_list
1918
from reusables.log import add_stream_handler
2019

reusables/file_operations.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
except ImportError:
2323
import configparser as ConfigParser
2424

25-
from reusables.namespace import *
26-
from reusables.shared_variables import *
25+
from reusables.namespace import ConfigNamespace
26+
from reusables.shared_variables import win_based, PY3, regex, variables, current_root
2727

2828
__all__ = [
2929
"load_json",
@@ -313,12 +313,7 @@ def save_json(data, json_file, indent=4, **kwargs):
313313
314314
... code::
315315
316-
{
317-
"key_1": "val_1",
318-
"key_for_dict": {
319-
"sub_dict_key": 8
320-
}
321-
}
316+
{"key_1": "val_1", "key_for_dict": {"sub_dict_key": 8}}
322317
323318
:param data: dictionary to save as JSON
324319
:param json_file: Path to save file location as str

reusables/log.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"""
1010

1111
from __future__ import absolute_import
12-
import warnings
1312
import logging
1413
import sys
1514
import io
@@ -22,7 +21,6 @@
2221

2322
__all__ = [
2423
"log_formats",
25-
"get_logger",
2624
"setup_logger",
2725
"get_registered_loggers",
2826
"get_file_handler",
@@ -61,12 +59,6 @@ def emit(self, record):
6159
logging.NullHandler = NullHandler
6260

6361

64-
def get_logger(*args, **kwargs):
65-
"""Depreciated, use setup_logger"""
66-
warnings.warn("get_logger is changing name to setup_logger", DeprecationWarning)
67-
return setup_logger(*args, **kwargs)
68-
69-
7062
def get_stream_handler(stream=sys.stderr, level=logging.INFO, log_format=log_formats.easy_read):
7163
"""
7264
Returns a set up stream handler to add to a logger.

reusables/process_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from multiprocessing import pool
1111
from functools import partial
1212

13-
from reusables.shared_variables import *
13+
from reusables.shared_variables import python_version, PY3
1414

1515
__all__ = ["run", "run_in_pool"]
1616

test/test_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
from reusables.cli import *
4-
from .common_test_data import *
3+
from reusables.cli import cmd, pushd, popd, pwd, cd, ls, find, head, cat, tail, cp
4+
from .common_test_data import BaseTestClass, data_dr, os
55

66

77
class TestCLI(BaseTestClass):

test/test_numbers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import reusables
33

4-
from .common_test_data import *
4+
from .common_test_data import BaseTestClass
55

66
roman_list = [
77
(1, "I"),

0 commit comments

Comments
 (0)