Skip to content

Commit

Permalink
Updated ruff config, fixed several legacy code issues
Browse files Browse the repository at this point in the history
  • Loading branch information
heuer committed Feb 23, 2024
1 parent 4ab9ac1 commit c3349df
Show file tree
Hide file tree
Showing 74 changed files with 160 additions and 296 deletions.
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# segno documentation build configuration file
#
Expand Down
19 changes: 8 additions & 11 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - 2024 -- Lars Heuer
# All rights reserved.
Expand Down Expand Up @@ -115,11 +114,11 @@ def start_release(session):
git('checkout', 'master')
prev_version = _get_current_version(session)
version = _validate_version(session)
valid_version = bool(int(session.run('python', '-c',
valid_version = bool(int(session.run('python', '-c',
'from packaging.version import parse;'
f'prev_version = parse("{prev_version}");'
f'next_version = parse("{version}");'
'print(1 if prev_version < next_version else 0)',
'print(1 if prev_version < next_version else 0)',
silent=True)))
if not valid_version:
session.error('Invalid version')
Expand Down Expand Up @@ -192,7 +191,7 @@ def _validate_version(session):
session.error('Too many arguments')
version = session.posargs[0]
if not re.match(r'^[0-9]+\.[0-9]+\.[0-9]+$', version):
session.error('Invalid version number: "{}"'.format(version))
session.error(f'Invalid version number: "{version}"')
return version


Expand All @@ -201,7 +200,7 @@ def _get_current_version(session):
Returns the current Segno version.
"""
fn = os.path.abspath(os.path.join(os.path.dirname(__file__), 'segno/__init__.py'))
with open(fn, 'r', encoding='utf-8') as f:
with open(fn, encoding='utf-8') as f:
content = f.read()
m = re.search(r'^__version__ = ["\']([^"\']+)["\']$', content, flags=re.MULTILINE)
if m:
Expand All @@ -214,15 +213,13 @@ def _change_version(session, previous_version, next_version):
Changes the segno.__init__.__version__ from previous_version to next_version.
"""
fn = os.path.abspath(os.path.join(os.path.dirname(__file__), 'segno/__init__.py'))
with open(fn, 'r', encoding='utf-8') as f:
with open(fn, encoding='utf-8') as f:
content = f.read()
new_content = re.sub(r'^(__version__ = ["\'])({0})(["\'])$'
.format(re.escape(previous_version)),
r'\g<1>{}\g<3>'.format(next_version), content,
new_content = re.sub(rf'^(__version__ = ["\'])({re.escape(previous_version)})(["\'])$',
rf'\g<1>{next_version}\g<3>', content,
flags=re.MULTILINE)
if content != new_content:
with open(fn, 'w', encoding='utf-8') as f:
f.write(new_content)
return
session.error('Cannot modify version. Provided: "{}" (previous) "{}" (next)'
.format(previous_version, next_version))
session.error(f'Cannot modify version. Provided: "{previous_version}" (previous) "{next_version}" (next)')
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,7 @@ directory = "data"


[tool.ruff]
exclude = ['examples']
lint.select = ['E', 'F', 'N', 'W', 'UP', 'RUF']
exclude = ['examples', 'tests']
line-length = 120

1 change: 0 additions & 1 deletion sandbox/benchmarks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
"""\
Some benchmarks running against QR Code generators
"""
Expand Down
1 change: 0 additions & 1 deletion sandbox/make_charts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
"""\
Create the benchmark charts.
"""
Expand Down
1 change: 0 additions & 1 deletion segno/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - 2024 -- Lars Heuer
# All rights reserved.
Expand Down
1 change: 0 additions & 1 deletion segno/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - 2024 -- Lars Heuer
# All rights reserved.
Expand Down
1 change: 0 additions & 1 deletion segno/consts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - 2024 -- Lars Heuer
# All rights reserved.
Expand Down
1 change: 0 additions & 1 deletion segno/encoder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - 2024 -- Lars Heuer
# All rights reserved.
Expand Down
1 change: 0 additions & 1 deletion segno/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - 2024 -- Lars Heuer
# All rights reserved.
Expand Down
1 change: 0 additions & 1 deletion segno/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 - 2024 -- Lars Heuer
# All rights reserved.
Expand Down
Loading

0 comments on commit c3349df

Please sign in to comment.