Skip to content

Commit

Permalink
ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed Nov 26, 2024
1 parent 7689eae commit 05a5182
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 121 deletions.
2 changes: 1 addition & 1 deletion python_utils/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
)
__url__: str = 'https://github.com/WoLpH/python-utils'
# Omit type info due to automatic versioning script
__version__ = '3.9.1'
__version__ = '3.9.0'
60 changes: 30 additions & 30 deletions python_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,44 +83,44 @@
)

__all__ = [
'CastedDict',
'LazyCastedDict',
'Logged',
'LoggerBase',
'UniqueList',
'abatcher',
'acount',
'aio',
'generators',
'aio_generator_timeout_detector',
'aio_generator_timeout_detector_decorator',
'aio_timeout_generator',
'batcher',
'camel_to_underscore',
'converters',
'decorators',
'delta_to_seconds',
'delta_to_seconds_or_none',
'format_time',
'formatters',
'generators',
'get_terminal_size',
'import_',
'import_global',
'listify',
'logger',
'terminal',
'time',
'types',
'to_int',
'to_float',
'to_unicode',
'to_str',
'scale_1024',
'raise_exception',
'remap',
'reraise',
'scale_1024',
'set_attributes',
'listify',
'camel_to_underscore',
'timesince',
'import_global',
'get_terminal_size',
'terminal',
'time',
'timedelta_to_seconds',
'format_time',
'timeout_generator',
'acount',
'abatcher',
'batcher',
'aio_timeout_generator',
'aio_generator_timeout_detector_decorator',
'aio_generator_timeout_detector',
'delta_to_seconds',
'delta_to_seconds_or_none',
'reraise',
'raise_exception',
'Logged',
'LoggerBase',
'CastedDict',
'LazyCastedDict',
'UniqueList',
'timesince',
'to_float',
'to_int',
'to_str',
'to_unicode',
'types',
]
4 changes: 2 additions & 2 deletions python_utils/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ def timesince(
for period, singular, plural in periods:
if int(period):
if int(period) == 1:
output.append('%d %s' % (period, singular))
output.append(f'{period:d} {singular}')
else:
output.append('%d %s' % (period, plural))
output.append(f'{period:d} {plural}')

if output:
return f'{" and ".join(output[:2])} ago'
Expand Down
168 changes: 84 additions & 84 deletions python_utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,128 +54,128 @@
]

__all__ = [
'OptionalScope',
'Number',
'DecimalNumber',
'delta_type',
'timestamp_type',
'IO',
'TYPE_CHECKING',
# ABCs (from collections.abc).
'AbstractSet',
# The types from the typing module.
# Super-special typing primitives.
'Annotated',
'Any',
# One-off things.
'AnyStr',
'AsyncContextManager',
'AsyncGenerator',
'AsyncGeneratorType',
'AsyncIterable',
'AsyncIterator',
'Awaitable',
# Other concrete types.
'BinaryIO',
'BuiltinFunctionType',
'BuiltinMethodType',
'ByteString',
'Callable',
# Concrete collection types.
'ChainMap',
'ClassMethodDescriptorType',
'ClassVar',
'CodeType',
'Collection',
'Concatenate',
'Container',
'ContextManager',
'Coroutine',
'CoroutineType',
'Counter',
'DecimalNumber',
'DefaultDict',
'Deque',
'Dict',
'DynamicClassAttribute',
'Final',
'ForwardRef',
'FrameType',
'FrozenSet',
# Types from the `types` module.
'FunctionType',
'Generator',
'GeneratorType',
'Generic',
'Literal',
'SupportsIndex',
'Optional',
'ParamSpec',
'ParamSpecArgs',
'ParamSpecKwargs',
'Protocol',
'Tuple',
'Type',
'TypeVar',
'Union',
# ABCs (from collections.abc).
'AbstractSet',
'ByteString',
'Container',
'ContextManager',
'GetSetDescriptorType',
'Hashable',
'ItemsView',
'Iterable',
'Iterator',
'KeysView',
'LambdaType',
'List',
'Literal',
'Mapping',
'MappingProxyType',
'MappingView',
'Match',
'MemberDescriptorType',
'MethodDescriptorType',
'MethodType',
'MethodWrapperType',
'ModuleType',
'MutableMapping',
'MutableSequence',
'MutableSet',
'Sequence',
'Sized',
'ValuesView',
'Awaitable',
'AsyncIterator',
'AsyncIterable',
'Coroutine',
'Collection',
'AsyncGenerator',
'AsyncContextManager',
'NamedTuple', # Not really a type.
'NewType',
'NoReturn',
'Number',
'Optional',
'OptionalScope',
'OrderedDict',
'ParamSpec',
'ParamSpecArgs',
'ParamSpecKwargs',
'Pattern',
'Protocol',
# Structural checks, a.k.a. protocols.
'Reversible',
'Sequence',
'Set',
'SimpleNamespace',
'Sized',
'SupportsAbs',
'SupportsBytes',
'SupportsComplex',
'SupportsFloat',
'SupportsIndex',
'SupportsIndex',
'SupportsInt',
'SupportsRound',
# Concrete collection types.
'ChainMap',
'Counter',
'Deque',
'Dict',
'DefaultDict',
'List',
'OrderedDict',
'Set',
'FrozenSet',
'NamedTuple', # Not really a type.
'TypedDict', # Not really a type.
'Generator',
# Other concrete types.
'BinaryIO',
'IO',
'Match',
'Pattern',
'Text',
'TextIO',
# One-off things.
'AnyStr',
'TracebackType',
'TracebackType',
'Tuple',
'Type',
'TypeAlias',
'TypeGuard',
'TypeVar',
'TypedDict', # Not really a type.
'Union',
'ValuesView',
'WrapperDescriptorType',
'cast',
'coroutine',
'delta_type',
'final',
'get_args',
'get_origin',
'get_type_hints',
'is_typeddict',
'NewType',
'new_class',
'no_type_check',
'no_type_check_decorator',
'NoReturn',
'overload',
'runtime_checkable',
'Text',
'TYPE_CHECKING',
'TypeAlias',
'TypeGuard',
'TracebackType',
# Types from the `types` module.
'FunctionType',
'LambdaType',
'CodeType',
'MappingProxyType',
'SimpleNamespace',
'GeneratorType',
'CoroutineType',
'AsyncGeneratorType',
'MethodType',
'BuiltinFunctionType',
'BuiltinMethodType',
'WrapperDescriptorType',
'MethodWrapperType',
'MethodDescriptorType',
'ClassMethodDescriptorType',
'ModuleType',
'TracebackType',
'FrameType',
'GetSetDescriptorType',
'MemberDescriptorType',
'new_class',
'resolve_bases',
'prepare_class',
'DynamicClassAttribute',
'coroutine',
'resolve_bases',
'runtime_checkable',
'timestamp_type',
]
15 changes: 11 additions & 4 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ target-version = 'py39'
exclude = [
'.venv',
'.tox',
# Ignore local test files/directories/old-stuff
'test.py',
'*_old.py',
]

lint.ignore = [
line-length = 79

[lint]
ignore = [
'A001', # Variable {name} is shadowing a Python builtin
'A002', # Argument {name} is shadowing a Python builtin
'A003', # Class attribute {name} is shadowing a Python builtin
Expand All @@ -27,13 +32,14 @@ lint.ignore = [
'RET506', # Unnecessary `else` after `raise` statement
'Q001', # Remove bad quotes
'Q002', # Remove bad quotes
'FA100', # Missing `from __future__ import annotations`, but uses `typing.Optional`
'COM812', # Missing trailing comma in a list
'ISC001', # String concatenation with implicit str conversion
'SIM108', # Ternary operators are not always more readable
'RUF100', # Unused `noqa` directive. These vary per Python version so this warning is often incorrect.
'RUF100', # Unused noqa directives. Due to multiple Python versions, we need to keep them
]
line-length = 79
lint.select = [

select = [
'A', # flake8-builtins
'ASYNC', # flake8 async checker
'B', # flake8-bugbear
Expand Down Expand Up @@ -105,3 +111,4 @@ max-line-length = 79

[lint.flake8-pytest-style]
mark-parentheses = true

0 comments on commit 05a5182

Please sign in to comment.