Skip to content

Commit

Permalink
chg: dev: remove py38 from test matrix
Browse files Browse the repository at this point in the history
* xform_id(id, strip) needs at least py39 if strip is True, so
  fallback to nothing if no member attribute
* skip strip test on < py39

Signed-off-by: Stephen L Arnold <nerdboy@gentoo.org>
  • Loading branch information
sarnold committed May 29, 2024
1 parent 91caae0 commit 4469cdb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-latest, windows-latest]
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Set git crlf/eol
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-latest, windows-latest]
python-version: [3.8, 3.9, '3.10', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- name: Set git crlf/eol
Expand Down
6 changes: 5 additions & 1 deletion src/yaml_tools/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Template bits for generating SSG-style controls in YAML.
"""

import inspect

from .utils import pystache_render

PROFILES = ['LOW', 'MODERATE', 'HIGH', 'PRIVACY']
Expand Down Expand Up @@ -59,7 +61,9 @@ def xform_id(string, strip_trailing_zeros=False):
AC-12(2) <==> ac-12.2
"""
if '(' in string or string[0].isupper():
if strip_trailing_zeros:
# we need to check for older-than-py39 here
has_rmsfx_attr = [x for x in inspect.getmembers('str') if 'removesuffix' in x]
if strip_trailing_zeros and has_rmsfx_attr:
string = string.removesuffix('-00')
return string.replace('(', '.').replace(')', '').lower()

Expand Down
1 change: 1 addition & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def test_xform_id():
assert xform_id(y) == x


@pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9 or higher")
def test_xform_id_strip():
stripped = xform_id('AC-08-00', True)
assert stripped == 'ac-08'
Expand Down

0 comments on commit 4469cdb

Please sign in to comment.