Skip to content

Commit bc653da

Browse files
authored
Add Python 3.12 (#285)
* fix packaging tox job * add py312 to tox, setup.py, and github actions, plus refresh requirements * upgrade syntax to py37+ and autoconvert some f-strings. add tox syntax-upgrade task.
1 parent 24c21dc commit bc653da

31 files changed

+260
-227
lines changed

.github/workflows/tests.yaml

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ name: Tests
22
on:
33
push:
44
paths-ignore:
5-
- 'docs/**'
6-
- '*.md'
7-
- '*.rst'
5+
- "docs/**"
6+
- "*.md"
7+
- "*.rst"
88
pull_request:
99
paths-ignore:
10-
- 'docs/**'
11-
- '*.md'
12-
- '*.rst'
10+
- "docs/**"
11+
- "*.md"
12+
- "*.rst"
1313
jobs:
1414
tests:
1515
name: ${{ matrix.name }}
@@ -18,14 +18,15 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
include:
21-
- {name: Linux, python: '3.11', os: ubuntu-latest, tox: py311}
22-
- {name: Windows, python: '3.11', os: windows-latest, tox: py311}
23-
- {name: Mac, python: '3.11', os: macos-latest, tox: py311}
24-
- {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310}
25-
- {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39}
26-
- {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
27-
- {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37}
28-
- {name: 'PyPy3', python: 'pypy-3.9', os: ubuntu-latest, tox: pypy3}
21+
- { name: Linux, python: "3.12", os: ubuntu-latest, tox: py312 }
22+
- { name: Windows, python: "3.12", os: windows-latest, tox: py312 }
23+
- { name: Mac, python: "3.12", os: macos-latest, tox: py312 }
24+
- { name: "3.11", python: "3.11", os: ubuntu-latest, tox: py311 }
25+
- { name: "3.10", python: "3.10", os: ubuntu-latest, tox: py310 }
26+
- { name: "3.9", python: "3.9", os: ubuntu-latest, tox: py39 }
27+
- { name: "3.8", python: "3.8", os: ubuntu-latest, tox: py38 }
28+
- { name: "3.7", python: "3.7", os: ubuntu-latest, tox: py37 }
29+
- { name: "PyPy3", python: "pypy-3.9", os: ubuntu-latest, tox: pypy3 }
2930
steps:
3031
- uses: actions/checkout@v4
3132
- uses: actions/setup-python@v4
@@ -52,4 +53,3 @@ jobs:
5253
fail_ci_if_error: true
5354
files: ./.tox/coverage.xml
5455
token: ${{ secrets.CODECOV_TOKEN }}
55-

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# -- Project information -----------------------------------------------------
3333

3434
project = u'glom'
35-
copyright = u'2023, Mahmoud Hashemi'
35+
copyright = u'2024, Mahmoud Hashemi'
3636
author = u'Mahmoud Hashemi'
3737

3838
# The short X.Y version

glom/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from glom.core import (glom,
32
Fill,
43
Auto,

glom/__main__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from glom.cli import console_main
32

43
if __name__ == '__main__':

glom/cli.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"""
2929

3030

31-
from __future__ import print_function
3231

3332
import os
3433
import ast
@@ -65,7 +64,7 @@ def glom_cli(target, spec, indent, debug, inspect, scalar):
6564
try:
6665
result = glom.glom(target, spec)
6766
except GlomError as ge:
68-
print('%s: %s' % (ge.__class__.__name__, ge))
67+
print(f'{ge.__class__.__name__}: {ge}')
6968
return 1
7069

7170
if not indent:
@@ -177,10 +176,10 @@ def mw_get_target(next_, posargs_, target_file, target_format, spec_file, spec_f
177176
raise UsageError('expected spec file or spec argument, not both')
178177
elif spec_file:
179178
try:
180-
with open(spec_file, 'r') as f:
179+
with open(spec_file) as f:
181180
spec_text = f.read()
182-
except IOError as ose:
183-
raise UsageError('could not read spec file %r, got: %s' % (spec_file, ose))
181+
except OSError as ose:
182+
raise UsageError(f'could not read spec file {spec_file!r}, got: {ose}')
184183

185184
if not spec_text:
186185
spec = Path()
@@ -202,9 +201,9 @@ def mw_get_target(next_, posargs_, target_file, target_format, spec_file, spec_f
202201
target_text = sys.stdin.read()
203202
elif target_file:
204203
try:
205-
target_text = open(target_file, 'r').read()
206-
except IOError as ose:
207-
raise UsageError('could not read target file %r, got: %s' % (target_file, ose))
204+
target_text = open(target_file).read()
205+
except OSError as ose:
206+
raise UsageError(f'could not read target file {target_file!r}, got: {ose}')
208207
elif not target_text and not isatty(sys.stdin):
209208
target_text = sys.stdin.read()
210209

@@ -225,7 +224,7 @@ def _from_glom_import_star():
225224

226225
def _eval_python_full_spec(py_text):
227226
name = '__cli_glom_spec__'
228-
code_str = '%s = %s' % (name, py_text)
227+
code_str = f'{name} = {py_text}'
229228
env = _from_glom_import_star()
230229
spec = _compile_code(code_str, name=name, env=env)
231230
return spec

0 commit comments

Comments
 (0)