Skip to content

Commit 05a5182

Browse files
committed
ruff fixes
1 parent 7689eae commit 05a5182

File tree

5 files changed

+128
-121
lines changed

5 files changed

+128
-121
lines changed

python_utils/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
)
2020
__url__: str = 'https://github.com/WoLpH/python-utils'
2121
# Omit type info due to automatic versioning script
22-
__version__ = '3.9.1'
22+
__version__ = '3.9.0'

python_utils/__init__.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,44 +83,44 @@
8383
)
8484

8585
__all__ = [
86+
'CastedDict',
87+
'LazyCastedDict',
88+
'Logged',
89+
'LoggerBase',
90+
'UniqueList',
91+
'abatcher',
92+
'acount',
8693
'aio',
87-
'generators',
94+
'aio_generator_timeout_detector',
95+
'aio_generator_timeout_detector_decorator',
96+
'aio_timeout_generator',
97+
'batcher',
98+
'camel_to_underscore',
8899
'converters',
89100
'decorators',
101+
'delta_to_seconds',
102+
'delta_to_seconds_or_none',
103+
'format_time',
90104
'formatters',
105+
'generators',
106+
'get_terminal_size',
91107
'import_',
108+
'import_global',
109+
'listify',
92110
'logger',
93-
'terminal',
94-
'time',
95-
'types',
96-
'to_int',
97-
'to_float',
98-
'to_unicode',
99-
'to_str',
100-
'scale_1024',
111+
'raise_exception',
101112
'remap',
113+
'reraise',
114+
'scale_1024',
102115
'set_attributes',
103-
'listify',
104-
'camel_to_underscore',
105-
'timesince',
106-
'import_global',
107-
'get_terminal_size',
116+
'terminal',
117+
'time',
108118
'timedelta_to_seconds',
109-
'format_time',
110119
'timeout_generator',
111-
'acount',
112-
'abatcher',
113-
'batcher',
114-
'aio_timeout_generator',
115-
'aio_generator_timeout_detector_decorator',
116-
'aio_generator_timeout_detector',
117-
'delta_to_seconds',
118-
'delta_to_seconds_or_none',
119-
'reraise',
120-
'raise_exception',
121-
'Logged',
122-
'LoggerBase',
123-
'CastedDict',
124-
'LazyCastedDict',
125-
'UniqueList',
120+
'timesince',
121+
'to_float',
122+
'to_int',
123+
'to_str',
124+
'to_unicode',
125+
'types',
126126
]

python_utils/formatters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ def timesince(
163163
for period, singular, plural in periods:
164164
if int(period):
165165
if int(period) == 1:
166-
output.append('%d %s' % (period, singular))
166+
output.append(f'{period:d} {singular}')
167167
else:
168-
output.append('%d %s' % (period, plural))
168+
output.append(f'{period:d} {plural}')
169169

170170
if output:
171171
return f'{" and ".join(output[:2])} ago'

python_utils/types.py

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -54,128 +54,128 @@
5454
]
5555

5656
__all__ = [
57-
'OptionalScope',
58-
'Number',
59-
'DecimalNumber',
60-
'delta_type',
61-
'timestamp_type',
57+
'IO',
58+
'TYPE_CHECKING',
59+
# ABCs (from collections.abc).
60+
'AbstractSet',
6261
# The types from the typing module.
6362
# Super-special typing primitives.
6463
'Annotated',
6564
'Any',
65+
# One-off things.
66+
'AnyStr',
67+
'AsyncContextManager',
68+
'AsyncGenerator',
69+
'AsyncGeneratorType',
70+
'AsyncIterable',
71+
'AsyncIterator',
72+
'Awaitable',
73+
# Other concrete types.
74+
'BinaryIO',
75+
'BuiltinFunctionType',
76+
'BuiltinMethodType',
77+
'ByteString',
6678
'Callable',
79+
# Concrete collection types.
80+
'ChainMap',
81+
'ClassMethodDescriptorType',
6782
'ClassVar',
83+
'CodeType',
84+
'Collection',
6885
'Concatenate',
86+
'Container',
87+
'ContextManager',
88+
'Coroutine',
89+
'CoroutineType',
90+
'Counter',
91+
'DecimalNumber',
92+
'DefaultDict',
93+
'Deque',
94+
'Dict',
95+
'DynamicClassAttribute',
6996
'Final',
7097
'ForwardRef',
98+
'FrameType',
99+
'FrozenSet',
100+
# Types from the `types` module.
101+
'FunctionType',
102+
'Generator',
103+
'GeneratorType',
71104
'Generic',
72-
'Literal',
73-
'SupportsIndex',
74-
'Optional',
75-
'ParamSpec',
76-
'ParamSpecArgs',
77-
'ParamSpecKwargs',
78-
'Protocol',
79-
'Tuple',
80-
'Type',
81-
'TypeVar',
82-
'Union',
83-
# ABCs (from collections.abc).
84-
'AbstractSet',
85-
'ByteString',
86-
'Container',
87-
'ContextManager',
105+
'GetSetDescriptorType',
88106
'Hashable',
89107
'ItemsView',
90108
'Iterable',
91109
'Iterator',
92110
'KeysView',
111+
'LambdaType',
112+
'List',
113+
'Literal',
93114
'Mapping',
115+
'MappingProxyType',
94116
'MappingView',
117+
'Match',
118+
'MemberDescriptorType',
119+
'MethodDescriptorType',
120+
'MethodType',
121+
'MethodWrapperType',
122+
'ModuleType',
95123
'MutableMapping',
96124
'MutableSequence',
97125
'MutableSet',
98-
'Sequence',
99-
'Sized',
100-
'ValuesView',
101-
'Awaitable',
102-
'AsyncIterator',
103-
'AsyncIterable',
104-
'Coroutine',
105-
'Collection',
106-
'AsyncGenerator',
107-
'AsyncContextManager',
126+
'NamedTuple', # Not really a type.
127+
'NewType',
128+
'NoReturn',
129+
'Number',
130+
'Optional',
131+
'OptionalScope',
132+
'OrderedDict',
133+
'ParamSpec',
134+
'ParamSpecArgs',
135+
'ParamSpecKwargs',
136+
'Pattern',
137+
'Protocol',
108138
# Structural checks, a.k.a. protocols.
109139
'Reversible',
140+
'Sequence',
141+
'Set',
142+
'SimpleNamespace',
143+
'Sized',
110144
'SupportsAbs',
111145
'SupportsBytes',
112146
'SupportsComplex',
113147
'SupportsFloat',
114148
'SupportsIndex',
149+
'SupportsIndex',
115150
'SupportsInt',
116151
'SupportsRound',
117-
# Concrete collection types.
118-
'ChainMap',
119-
'Counter',
120-
'Deque',
121-
'Dict',
122-
'DefaultDict',
123-
'List',
124-
'OrderedDict',
125-
'Set',
126-
'FrozenSet',
127-
'NamedTuple', # Not really a type.
128-
'TypedDict', # Not really a type.
129-
'Generator',
130-
# Other concrete types.
131-
'BinaryIO',
132-
'IO',
133-
'Match',
134-
'Pattern',
152+
'Text',
135153
'TextIO',
136-
# One-off things.
137-
'AnyStr',
154+
'TracebackType',
155+
'TracebackType',
156+
'Tuple',
157+
'Type',
158+
'TypeAlias',
159+
'TypeGuard',
160+
'TypeVar',
161+
'TypedDict', # Not really a type.
162+
'Union',
163+
'ValuesView',
164+
'WrapperDescriptorType',
138165
'cast',
166+
'coroutine',
167+
'delta_type',
139168
'final',
140169
'get_args',
141170
'get_origin',
142171
'get_type_hints',
143172
'is_typeddict',
144-
'NewType',
173+
'new_class',
145174
'no_type_check',
146175
'no_type_check_decorator',
147-
'NoReturn',
148176
'overload',
149-
'runtime_checkable',
150-
'Text',
151-
'TYPE_CHECKING',
152-
'TypeAlias',
153-
'TypeGuard',
154-
'TracebackType',
155-
# Types from the `types` module.
156-
'FunctionType',
157-
'LambdaType',
158-
'CodeType',
159-
'MappingProxyType',
160-
'SimpleNamespace',
161-
'GeneratorType',
162-
'CoroutineType',
163-
'AsyncGeneratorType',
164-
'MethodType',
165-
'BuiltinFunctionType',
166-
'BuiltinMethodType',
167-
'WrapperDescriptorType',
168-
'MethodWrapperType',
169-
'MethodDescriptorType',
170-
'ClassMethodDescriptorType',
171-
'ModuleType',
172-
'TracebackType',
173-
'FrameType',
174-
'GetSetDescriptorType',
175-
'MemberDescriptorType',
176-
'new_class',
177-
'resolve_bases',
178177
'prepare_class',
179-
'DynamicClassAttribute',
180-
'coroutine',
178+
'resolve_bases',
179+
'runtime_checkable',
180+
'timestamp_type',
181181
]

ruff.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ target-version = 'py39'
66
exclude = [
77
'.venv',
88
'.tox',
9+
# Ignore local test files/directories/old-stuff
910
'test.py',
11+
'*_old.py',
1012
]
1113

12-
lint.ignore = [
14+
line-length = 79
15+
16+
[lint]
17+
ignore = [
1318
'A001', # Variable {name} is shadowing a Python builtin
1419
'A002', # Argument {name} is shadowing a Python builtin
1520
'A003', # Class attribute {name} is shadowing a Python builtin
@@ -27,13 +32,14 @@ lint.ignore = [
2732
'RET506', # Unnecessary `else` after `raise` statement
2833
'Q001', # Remove bad quotes
2934
'Q002', # Remove bad quotes
35+
'FA100', # Missing `from __future__ import annotations`, but uses `typing.Optional`
3036
'COM812', # Missing trailing comma in a list
3137
'ISC001', # String concatenation with implicit str conversion
3238
'SIM108', # Ternary operators are not always more readable
33-
'RUF100', # Unused `noqa` directive. These vary per Python version so this warning is often incorrect.
39+
'RUF100', # Unused noqa directives. Due to multiple Python versions, we need to keep them
3440
]
35-
line-length = 79
36-
lint.select = [
41+
42+
select = [
3743
'A', # flake8-builtins
3844
'ASYNC', # flake8 async checker
3945
'B', # flake8-bugbear
@@ -105,3 +111,4 @@ max-line-length = 79
105111

106112
[lint.flake8-pytest-style]
107113
mark-parentheses = true
114+

0 commit comments

Comments
 (0)