Skip to content

Commit 85329e3

Browse files
authored
drop python<=3.7 support (#101)
* drop python<=3.7 support iAccording to https://endoflife.date/python python 3.7 has been EOSed 27 Jun 2023. Filter all python cde over `pyupgrade --py38-plus`. Signed-off-by: Tomasz Kłoczko <[email protected]> * update classifiers and remove mock as it is no longer needed Bump as well minimum pyton version to 3.8. Signed-off-by: Tomasz Kłoczko <[email protected]> * remove unused imports Filter all code over `ruff check --fix .`. Signed-off-by: Tomasz Kłoczko <[email protected]> * remove python 3.7 from gh workflows as it is no longer needed Signed-off-by: Tomasz Kłoczko <[email protected]> --------- Signed-off-by: Tomasz Kłoczko <[email protected]>
1 parent 8763432 commit 85329e3

16 files changed

+36
-60
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12', '3.13']
14+
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']
1515
max-parallel: 1
1616

1717
steps:

pyproject.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [
66
]
77
description = "Sphinx utility that make it easy to translate and to apply translation."
88
readme = "README.rst"
9-
requires-python = ">=3.7"
9+
requires-python = ">=3.8"
1010
license = {file = "LICENSE"}
1111
dependencies = [
1212
"setuptools",
@@ -26,9 +26,6 @@ classifiers = [
2626
"Topic :: Text Processing :: General",
2727
"Topic :: Utilities",
2828
"Operating System :: OS Independent",
29-
"Programming Language :: Python",
30-
"Programming Language :: Python :: 3",
31-
"Programming Language :: Python :: 3.7",
3229
"Programming Language :: Python :: 3.8",
3330
"Programming Language :: Python :: 3.9",
3431
"Programming Language :: Python :: 3.10",
@@ -41,7 +38,6 @@ classifiers = [
4138
[project.optional-dependencies]
4239
test = [
4340
"pytest",
44-
"mock",
4541
]
4642

4743
[project.urls]

sphinx_intl/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
# -*- coding: utf-8 -*-
2-
31
__version__ = '2.3.0'

sphinx_intl/__main__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
if __name__ == '__main__':
42
from sphinx_intl.commands import main
53
main()

sphinx_intl/basic.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import os
42
from glob import glob
53

@@ -53,23 +51,23 @@ def update(locale_dir, pot_dir, languages, line_width=76, ignore_obsolete=False)
5351
cat_pot = c.load_po(pot_file)
5452
if os.path.exists(po_file):
5553
cat = c.load_po(po_file)
56-
msgids = set([m.id for m in cat if m.id])
54+
msgids = {m.id for m in cat if m.id}
5755
c.update_with_fuzzy(cat, cat_pot)
58-
new_msgids = set([m.id for m in cat if m.id])
56+
new_msgids = {m.id for m in cat if m.id}
5957
if msgids != new_msgids:
6058
added = new_msgids - msgids
6159
deleted = msgids - new_msgids
6260
status['update'] += 1
63-
click.echo('Update: {0} +{1}, -{2}'.format(
61+
click.echo('Update: {} +{}, -{}'.format(
6462
po_file, len(added), len(deleted)))
6563
c.dump_po(po_file, cat, width=line_width,
6664
ignore_obsolete=ignore_obsolete)
6765
else:
6866
status['notchanged'] += 1
69-
click.echo('Not Changed: {0}'.format(po_file))
67+
click.echo(f'Not Changed: {po_file}')
7068
else: # new po file
7169
status['create'] += 1
72-
click.echo('Create: {0}'.format(po_file))
70+
click.echo(f'Create: {po_file}')
7371
cat_pot.locale = lang
7472
c.dump_po(po_file, cat_pot, width=line_width,
7573
ignore_obsolete=ignore_obsolete)
@@ -102,7 +100,7 @@ def build(locale_dir, output_dir, languages):
102100
if (os.path.exists(mo_file) and
103101
os.path.getmtime(mo_file) > os.path.getmtime(po_file)):
104102
continue
105-
click.echo('Build: {0}'.format(mo_file))
103+
click.echo(f'Build: {mo_file}')
106104
cat = c.load_po(po_file)
107105
c.write_mo(mo_file, cat)
108106

@@ -134,7 +132,7 @@ def stat(locale_dir, languages):
134132
'untranslated': len(c.untranslated_entries(cat)),
135133
}
136134
click.echo(
137-
'{0}: {1} translated, {2} fuzzy, {3} untranslated.'.format(
135+
'{}: {} translated, {} fuzzy, {} untranslated.'.format(
138136
po_file,
139137
r['translated'],
140138
r['fuzzy'],

sphinx_intl/catalog.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# -*- coding: utf-8 -*-
2-
31
import os
4-
import io
52

63
from babel.messages import pofile, mofile
74

@@ -14,13 +11,13 @@ def load_po(filename, **kwargs):
1411
:return: catalog object
1512
"""
1613
# pre-read to get charset
17-
with io.open(filename, 'rb') as f:
14+
with open(filename, 'rb') as f:
1815
cat = pofile.read_po(f)
1916
charset = cat.charset or 'utf-8'
2017

2118
# To decode lines by babel, read po file as binary mode and specify charset for
2219
# read_po function.
23-
with io.open(filename, 'rb') as f: # FIXME: encoding VS charset
20+
with open(filename, 'rb') as f: # FIXME: encoding VS charset
2421
return pofile.read_po(f, charset=charset, **kwargs)
2522

2623

@@ -46,7 +43,7 @@ def dump_po(filename, catalog, **kwargs):
4643
del kwargs['line_width']
4744

4845
# Because babel automatically encode strings, file should be open as binary mode.
49-
with io.open(filename, 'wb') as f:
46+
with open(filename, 'wb') as f:
5047
pofile.write_po(f, catalog, **kwargs)
5148

5249

@@ -60,7 +57,7 @@ def write_mo(filename, catalog, **kwargs):
6057
dirname = os.path.dirname(filename)
6158
if not os.path.exists(dirname):
6259
os.makedirs(dirname)
63-
with io.open(filename, 'wb') as f:
60+
with open(filename, 'wb') as f:
6461
mofile.write_mo(f, catalog, **kwargs)
6562

6663

sphinx_intl/commands.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
sphinx-intl
43
~~~~~~~~~~~
@@ -196,11 +195,11 @@ def main(ctx, config, tag):
196195
ctx.transifex_project_name = None
197196
target = os.path.normpath('.tx/config')
198197
if os.path.exists(target):
199-
matched = re.search(r'\[(.*)\..*\]', open(target, 'r').read())
198+
matched = re.search(r'\[(.*)\..*\]', open(target).read())
200199
if matched:
201200
ctx.transifex_project_name = matched.groups()[0]
202201
click.echo(
203-
'Project name loaded from .tx/config: {0}'.format(
202+
'Project name loaded from .tx/config: {}'.format(
204203
ctx.transifex_project_name))
205204

206205
ctx.default_map = {

sphinx_intl/sphinx_util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# -*- coding: utf-8 -*-
21
from typing import Iterator, List
32

43

54
# port from https://github.com/sphinx-doc/sphinx/blob/ad41e0b/sphinx/util/tags.py
6-
class Tags(object):
5+
class Tags:
76
def __init__(self, tags: List[str] = None) -> None:
87
self.tags = dict.fromkeys(tags or [], True)
98

sphinx_intl/transifex.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import os
42
import re
53
import subprocess
@@ -108,7 +106,7 @@ def create_transifexrc(transifex_token):
108106
target = os.path.normpath(os.path.expanduser('~/.transifexrc'))
109107

110108
if os.path.exists(target):
111-
click.echo('{0} already exists, skipped.'.format(target))
109+
click.echo(f'{target} already exists, skipped.')
112110
return
113111

114112
if not transifex_token:
@@ -118,9 +116,9 @@ def create_transifexrc(transifex_token):
118116
""")
119117
raise click.BadParameter(msg, param_hint='transifex_token')
120118

121-
with open(target, 'wt') as rc:
119+
with open(target, 'w') as rc:
122120
rc.write(TRANSIFEXRC_TEMPLATE % locals())
123-
click.echo('Create: {0}'.format(target))
121+
click.echo(f'Create: {target}')
124122

125123

126124
def create_txconfig():
@@ -129,16 +127,16 @@ def create_txconfig():
129127
"""
130128
target = os.path.normpath('.tx/config')
131129
if os.path.exists(target):
132-
click.echo('{0} already exists, skipped.'.format(target))
130+
click.echo(f'{target} already exists, skipped.')
133131
return
134132

135133
if not os.path.exists('.tx'):
136134
os.mkdir('.tx')
137135

138-
with open(target, 'wt') as f:
136+
with open(target, 'w') as f:
139137
f.write(TXCONFIG_TEMPLATE)
140138

141-
click.echo('Create: {0}'.format(target))
139+
click.echo(f'Create: {target}')
142140

143141

144142
def update_txconfig_resources(transifex_organization_name, transifex_project_name,
@@ -182,4 +180,4 @@ def update_txconfig_resources(transifex_organization_name, transifex_project_nam
182180
cmd = [arg % lv for arg in cmd_tmpl]
183181
subprocess.check_output(cmd, shell=False)
184182
else:
185-
click.echo('{0} is empty, skipped'.format(pot_path))
183+
click.echo(f'{pot_path} is empty, skipped')

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
conftest
43
~~~~~~~~

0 commit comments

Comments
 (0)