Skip to content

Commit d56c051

Browse files
authored
Merge pull request #84 from acsone/pre-commit-sbi
A little bit of modernization
2 parents 8288ebf + a0dcb3f commit d56c051

File tree

15 files changed

+54
-48
lines changed

15 files changed

+54
-48
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ default_language_version:
22
python: python3
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.0.1
5+
rev: v5.0.0
66
hooks:
77
- id: check-toml
88
- id: check-yaml
99
- id: end-of-file-fixer
1010
- id: trailing-whitespace
11-
- repo: https://github.com/PyCQA/flake8
12-
rev: "3.9.2"
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.7.0
1313
hooks:
14-
- id: flake8
14+
- id: ruff
15+
args: [--fix]

git_aggregator/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
# -*- coding: utf-8 -*-
21
# © 2015 ACSONE SA/NV
32
# License AGPLv3 (http://www.gnu.org/licenses/agpl-3.0-standalone.html)

git_aggregator/_compat.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# © 2015 ACSONE SA/NV
32
# License AGPLv3 (http://www.gnu.org/licenses/agpl-3.0-standalone.html)
43
import sys

git_aggregator/config.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# © 2015 ACSONE SA/NV
32
# License AGPLv3 (http://www.gnu.org/licenses/agpl-3.0-standalone.html)
43

@@ -8,9 +7,8 @@
87

98
import yaml
109

11-
from .exception import ConfigException
1210
from ._compat import string_types
13-
11+
from .exception import ConfigException
1412

1513
log = logging.getLogger(__name__)
1614

@@ -167,11 +165,11 @@ def load_config(config, expand_env=False, env_file=None, force=False):
167165
key, value = line.split('=')
168166
environment.update({key.strip(): value.strip()})
169167
environment.update(os.environ)
170-
with open(config, 'r') as file_handler:
168+
with open(config) as file_handler:
171169
config = Template(file_handler.read())
172170
config = config.substitute(environment)
173171
else:
174-
config = open(config, 'r').read()
172+
config = open(config).read()
175173

176174
conf = yaml.load(config, Loader=yaml.SafeLoader)
177175

git_aggregator/exception.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# © 2015 ACSONE SA/NV
32
# License AGPLv3 (http://www.gnu.org/licenses/agpl-3.0-standalone.html)
43

git_aggregator/log.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# © 2015 ACSONE SA/NV
32
# License AGPLv3 (http://www.gnu.org/licenses/agpl-3.0-standalone.html)
43

git_aggregator/main.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# © 2015-2019 ACSONE SA/NV
32
# License AGPLv3 (http://www.gnu.org/licenses/agpl-3.0-standalone.html)
43

@@ -7,22 +6,24 @@
76
import sys
87
import threading
98
import traceback
9+
1010
try:
11-
from Queue import Queue, Empty as EmptyQueue
11+
from Queue import Empty as EmptyQueue
12+
from Queue import Queue
1213
except ImportError:
13-
from queue import Queue, Empty as EmptyQueue
14+
from queue import Empty as EmptyQueue
15+
from queue import Queue
1416

1517
import argparse
18+
import fnmatch
19+
1620
import argcomplete
1721
import colorama
18-
import fnmatch
1922

20-
from .utils import ThreadNameKeeper
21-
from .log import DebugLogFormatter
22-
from .log import LogFormatter
2323
from .config import load_config
24+
from .log import DebugLogFormatter, LogFormatter
2425
from .repo import Repo
25-
26+
from .utils import ThreadNameKeeper
2627

2728
logger = logging.getLogger(__name__)
2829

@@ -31,8 +32,7 @@
3132

3233
def _log_level_string_to_int(log_level_string):
3334
if log_level_string not in _LOG_LEVEL_STRINGS:
34-
message = 'invalid choice: {0} (choose from {1})'.format(
35-
log_level_string, _LOG_LEVEL_STRINGS)
35+
message = f'invalid choice: {log_level_string} (choose from {_LOG_LEVEL_STRINGS})'
3636
raise argparse.ArgumentTypeError(message)
3737

3838
log_level_int = getattr(logging, log_level_string, logging.INFO)
@@ -99,7 +99,7 @@ def get_parser():
9999
dest='log_level',
100100
type=_log_level_string_to_int,
101101
nargs='?',
102-
help='Set the logging output level. {0}'.format(_LOG_LEVEL_STRINGS))
102+
help=f'Set the logging output level. {_LOG_LEVEL_STRINGS}')
103103

104104
main_parser.add_argument(
105105
'-e', '--expand-env',

git_aggregator/repo.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
# -*- coding: utf-8 -*-
21
# © 2015 ACSONE SA/NV
32
# License AGPLv3 (http://www.gnu.org/licenses/agpl-3.0-standalone.html)
43
# Parts of the code comes from ANYBOX
54
# https://github.com/anybox/anybox.recipe.odoo
6-
from __future__ import unicode_literals
7-
import os
85
import logging
6+
import os
97
import re
108
import subprocess
119

1210
import requests
1311

14-
from .exception import DirtyException, GitAggregatorException
1512
from ._compat import console_to_str
13+
from .exception import DirtyException, GitAggregatorException
1614

1715
FETCH_DEFAULTS = ("depth", "shallow-since", "shallow-exclude")
1816
logger = logging.getLogger(__name__)
@@ -32,7 +30,7 @@ def ishex(s):
3230
return True
3331

3432

35-
class Repo(object):
33+
class Repo:
3634

3735
_git_version = None
3836

git_aggregator/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# -*- coding: utf-8 -*-
21
# © 2015 ACSONE SA/NV
32
# © ANYBOX https://github.com/anybox/anybox.recipe.odoo
43
# License AGPLv3 (http://www.gnu.org/licenses/agpl-3.0-standalone.html)
4+
import logging
55
import os
66
import threading
7-
import logging
7+
88
logger = logging.getLogger(__name__)
99

1010

11-
class WorkingDirectoryKeeper(object): # DEPRECATED
11+
class WorkingDirectoryKeeper: # DEPRECATED
1212
"""A context manager to get back the working directory as it was before.
1313
If you want to stack working directory keepers, you need a new instance
1414
for each stage.
@@ -30,7 +30,7 @@ def __exit__(self, *exc_args):
3030
working_directory_keeper = WorkingDirectoryKeeper()
3131

3232

33-
class ThreadNameKeeper(object):
33+
class ThreadNameKeeper:
3434
"""A contect manager to get back the thread name as it was before. It
3535
is meant to be used when modifying the 'MainThread' tread.
3636
"""

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[tool.ruff]
2+
fix = true
3+
line-length = 79
4+
5+
[tool.ruff.lint]
6+
extend-select = [
7+
"I",
8+
"UP",
9+
]
10+
ignore = [
11+
"UP031", # % formatting
12+
]
13+
14+
[tool.ruff.lint.isort]
15+
known-first-party = ["git_aggregator"]

0 commit comments

Comments
 (0)