Skip to content

Commit

Permalink
Add Python 3.12 (#285)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mahmoud authored Nov 2, 2024
1 parent 24c21dc commit bc653da
Show file tree
Hide file tree
Showing 31 changed files with 260 additions and 227 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: Tests
on:
push:
paths-ignore:
- 'docs/**'
- '*.md'
- '*.rst'
- "docs/**"
- "*.md"
- "*.rst"
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
- '*.rst'
- "docs/**"
- "*.md"
- "*.rst"
jobs:
tests:
name: ${{ matrix.name }}
Expand All @@ -18,14 +18,15 @@ jobs:
fail-fast: false
matrix:
include:
- {name: Linux, python: '3.11', os: ubuntu-latest, tox: py311}
- {name: Windows, python: '3.11', os: windows-latest, tox: py311}
- {name: Mac, python: '3.11', os: macos-latest, tox: py311}
- {name: '3.10', python: '3.10', os: ubuntu-latest, tox: py310}
- {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39}
- {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38}
- {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37}
- {name: 'PyPy3', python: 'pypy-3.9', os: ubuntu-latest, tox: pypy3}
- { name: Linux, python: "3.12", os: ubuntu-latest, tox: py312 }
- { name: Windows, python: "3.12", os: windows-latest, tox: py312 }
- { name: Mac, python: "3.12", os: macos-latest, tox: py312 }
- { name: "3.11", python: "3.11", os: ubuntu-latest, tox: py311 }
- { name: "3.10", python: "3.10", os: ubuntu-latest, tox: py310 }
- { name: "3.9", python: "3.9", os: ubuntu-latest, tox: py39 }
- { name: "3.8", python: "3.8", os: ubuntu-latest, tox: py38 }
- { name: "3.7", python: "3.7", os: ubuntu-latest, tox: py37 }
- { name: "PyPy3", python: "pypy-3.9", os: ubuntu-latest, tox: pypy3 }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
Expand All @@ -52,4 +53,3 @@ jobs:
fail_ci_if_error: true
files: ./.tox/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}

2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# -- Project information -----------------------------------------------------

project = u'glom'
copyright = u'2023, Mahmoud Hashemi'
copyright = u'2024, Mahmoud Hashemi'
author = u'Mahmoud Hashemi'

# The short X.Y version
Expand Down
1 change: 0 additions & 1 deletion glom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from glom.core import (glom,
Fill,
Auto,
Expand Down
1 change: 0 additions & 1 deletion glom/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from glom.cli import console_main

if __name__ == '__main__':
Expand Down
17 changes: 8 additions & 9 deletions glom/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"""


from __future__ import print_function

import os
import ast
Expand Down Expand Up @@ -65,7 +64,7 @@ def glom_cli(target, spec, indent, debug, inspect, scalar):
try:
result = glom.glom(target, spec)
except GlomError as ge:
print('%s: %s' % (ge.__class__.__name__, ge))
print(f'{ge.__class__.__name__}: {ge}')
return 1

if not indent:
Expand Down Expand Up @@ -177,10 +176,10 @@ def mw_get_target(next_, posargs_, target_file, target_format, spec_file, spec_f
raise UsageError('expected spec file or spec argument, not both')
elif spec_file:
try:
with open(spec_file, 'r') as f:
with open(spec_file) as f:
spec_text = f.read()
except IOError as ose:
raise UsageError('could not read spec file %r, got: %s' % (spec_file, ose))
except OSError as ose:
raise UsageError(f'could not read spec file {spec_file!r}, got: {ose}')

if not spec_text:
spec = Path()
Expand All @@ -202,9 +201,9 @@ def mw_get_target(next_, posargs_, target_file, target_format, spec_file, spec_f
target_text = sys.stdin.read()
elif target_file:
try:
target_text = open(target_file, 'r').read()
except IOError as ose:
raise UsageError('could not read target file %r, got: %s' % (target_file, ose))
target_text = open(target_file).read()
except OSError as ose:
raise UsageError(f'could not read target file {target_file!r}, got: {ose}')
elif not target_text and not isatty(sys.stdin):
target_text = sys.stdin.read()

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

def _eval_python_full_spec(py_text):
name = '__cli_glom_spec__'
code_str = '%s = %s' % (name, py_text)
code_str = f'{name} = {py_text}'
env = _from_glom_import_star()
spec = _compile_code(code_str, name=name, env=env)
return spec
Expand Down
Loading

0 comments on commit bc653da

Please sign in to comment.