Skip to content

Commit

Permalink
Merge pull request #259 from 23andMe/feature/py313
Browse files Browse the repository at this point in the history
Support 3.13, add [ruamel] optional package dep
  • Loading branch information
cblakkan authored Dec 31, 2024
2 parents 8a09315 + 6d42b81 commit b44ed27
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
python-version: ["3.8", "3.13"]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
version=version,
url="https://github.com/23andMe/Yamale",
author="Bo Lopker",
author_email="blopker@23andme.com",
author_email="dev-api@23andme.com",
description="A schema and validator for YAML.",
long_description=readme,
long_description_content_type="text/markdown",
license="MIT",
packages=find_packages(),
include_package_data=True,
install_requires=["pyyaml"],
extras_requires={"ruamel": ["ruamel.yaml"]},
python_requires=">=3.8",
entry_points={
"console_scripts": ["yamale=yamale.command_line:main"],
Expand All @@ -34,5 +35,6 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
)
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tox]
envlist = py38, py310
envlist = py38, py313

[gh-actions]
python =
3.8: py38
3.12: py312
3.13: py313

[testenv]
commands = py.test --cov yamale --cov-report term-missing yamale
Expand Down
2 changes: 1 addition & 1 deletion yamale/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.2.1
5.3.0
6 changes: 5 additions & 1 deletion yamale/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ def _router(paths, schema_name, cpus, parser, strict=True):
def main():
parser = argparse.ArgumentParser(description="Validate yaml files.")
parser.add_argument(
"paths", metavar="PATHS", default=["./"], nargs="*", help="Paths to validate, either directories or files. Default is the current directory."
"paths",
metavar="PATH",
default=["./"],
nargs="*",
help="Paths to validate, either directories or files. Default is the current directory.",
)
parser.add_argument("-V", "--version", action="version", version=__version__)
parser.add_argument("-s", "--schema", default="schema.yaml", help="filename of schema. Default is schema.yaml.")
Expand Down
26 changes: 18 additions & 8 deletions yamale/tests/test_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,28 @@ def test_good_yaml(parser):


def test_multiple_paths_good_yaml():
command_line._router([
"yamale/tests/command_line_fixtures/yamls/good.yaml",
"yamale/tests/command_line_fixtures/yamls/good2.yaml",
], "schema.yaml", 1, "PyYAML")
command_line._router(
[
"yamale/tests/command_line_fixtures/yamls/good.yaml",
"yamale/tests/command_line_fixtures/yamls/good2.yaml",
],
"schema.yaml",
1,
"PyYAML",
)


def test_multiple_paths_bad_yaml():
with pytest.raises(ValueError) as e:
command_line._router([
"yamale/tests/command_line_fixtures/yamls/good.yaml",
"yamale/tests/command_line_fixtures/yamls/bad.yaml",
], "schema.yaml", 1, "PyYAML")
command_line._router(
[
"yamale/tests/command_line_fixtures/yamls/good.yaml",
"yamale/tests/command_line_fixtures/yamls/bad.yaml",
],
"schema.yaml",
1,
"PyYAML",
)
assert "map.bad: '12.5' is not a int." in e.value.message


Expand Down
4 changes: 3 additions & 1 deletion yamale/validators/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ def __init__(self, *args, **kwargs):
super(SemVer, self).__init__(*args, **kwargs)
self.regexes = [
# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
re.compile(r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"),
re.compile(
r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
),
]


Expand Down

0 comments on commit b44ed27

Please sign in to comment.