From e05f8fc9128e57e0300a6270709b1ffa065c2907 Mon Sep 17 00:00:00 2001
From: Padraig Gleeson
Date: Wed, 29 Apr 2026 18:34:45 +0100
Subject: [PATCH 1/4] Update CI workflow to use bash shell for install step
---
.github/workflows/ci_test_all.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/ci_test_all.yml b/.github/workflows/ci_test_all.yml
index 1952f70..77a9f09 100644
--- a/.github/workflows/ci_test_all.yml
+++ b/.github/workflows/ci_test_all.yml
@@ -31,6 +31,7 @@ jobs:
brew install hdf5
- name: Install & test package
+ shell: bash
run: |
python -m pip install --upgrade pip
# pip install 'numpy<2.0.0' # due to lingering issues with other modules & numpy...
From 87c59888f25be4c8838a6e88a64fd665042479a4 Mon Sep 17 00:00:00 2001
From: Padraig Gleeson
Date: Wed, 29 Apr 2026 18:50:39 +0100
Subject: [PATCH 2/4] Updated docstringe for test example
---
examples/test/test.md | 6 +++---
examples/test/test.py | 8 ++++----
examples/test/test.specification.yaml | 7 ++++---
examples/test/test_instance.json | 2 +-
examples/test/test_instance.xml | 2 +-
examples/test/test_instance.yaml | 2 +-
6 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/examples/test/test.md b/examples/test/test.md
index ccfd2fe..b6af944 100644
--- a/examples/test/test.md
+++ b/examples/test/test.md
@@ -13,21 +13,21 @@ A model....
| float_like_req |
float |
- name says it all... |
+ Anything (float, str, int) which can be converted to a float with float(x) |
| float_like_optional |
float |
- name also says it all... |
+ Same as floatlikereq, but optional |
| int_like_optional |
int |
- name also says it all... |
+ Same as floatlikereq, but optional int |
diff --git a/examples/test/test.py b/examples/test/test.py
index afa628b..d082c5f 100644
--- a/examples/test/test.py
+++ b/examples/test/test.py
@@ -48,9 +48,9 @@ class TopClass(Base):
Args:
id: The unique id of the thing
- float_like_req: name says it all...
- float_like_optional: name also says it all...
- int_like_optional: name also says it all...
+ float_like_req: Anything (float, str, int) which can be converted to a float with float(x)
+ float_like_optional: Same as float_like_req, but optional
+ int_like_optional: Same as float_like_req, but optional int
"""
id: str = field(validator=instance_of(str))
@@ -74,7 +74,7 @@ class TopClass(Base):
) # a string which can be converted to a float...
# tc.float_like_req = 2.01
-tc.float_like_optional = 44
+tc.float_like_optional = "42"
# tc.float_like_optional2 = 66
tc.mid = MidClassNoId(int_val=4, str_val="three")
diff --git a/examples/test/test.specification.yaml b/examples/test/test.specification.yaml
index 4ffaa7a..57f2917 100644
--- a/examples/test/test.specification.yaml
+++ b/examples/test/test.specification.yaml
@@ -6,13 +6,14 @@ TopClass:
description: The unique id of the thing
float_like_req:
type: float
- description: name says it all...
+ description: Anything (float, str, int) which can be converted to a float
+ with float(x)
float_like_optional:
type: float
- description: name also says it all...
+ description: Same as float_like_req, but optional
int_like_optional:
type: int
- description: name also says it all...
+ description: Same as float_like_req, but optional int
mid:
type: MidClassNoId
description: ''
diff --git a/examples/test/test_instance.json b/examples/test/test_instance.json
index 7b8b087..47de2a3 100644
--- a/examples/test/test_instance.json
+++ b/examples/test/test_instance.json
@@ -1,7 +1,7 @@
{
"MyTest": {
"float_like_req": 4.0,
- "float_like_optional": 44.0,
+ "float_like_optional": 42.0,
"mid": {
"int_val": 4,
"str_val": "three"
diff --git a/examples/test/test_instance.xml b/examples/test/test_instance.xml
index 4895ba5..496b084 100644
--- a/examples/test/test_instance.xml
+++ b/examples/test/test_instance.xml
@@ -1,4 +1,4 @@
-
+
diff --git a/examples/test/test_instance.yaml b/examples/test/test_instance.yaml
index 1a3bcd4..f64bbfe 100644
--- a/examples/test/test_instance.yaml
+++ b/examples/test/test_instance.yaml
@@ -1,6 +1,6 @@
MyTest:
float_like_req: 4.0
- float_like_optional: 44.0
+ float_like_optional: 42.0
mid:
int_val: 4
str_val: three
From cc0bbafe63d35672bbd85e6b3a8e5a1ba35ed467 Mon Sep 17 00:00:00 2001
From: Padraig Gleeson
Date: Wed, 29 Apr 2026 18:50:51 +0100
Subject: [PATCH 3/4] update gha env for windows
---
.github/workflows/ci_test_all.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/ci_test_all.yml b/.github/workflows/ci_test_all.yml
index 77a9f09..789b8d4 100644
--- a/.github/workflows/ci_test_all.yml
+++ b/.github/workflows/ci_test_all.yml
@@ -32,6 +32,9 @@ jobs:
- name: Install & test package
shell: bash
+ env:
+ PYTHONUTF8: "1"
+ PYTHONIOENCODING: "utf-8"
run: |
python -m pip install --upgrade pip
# pip install 'numpy<2.0.0' # due to lingering issues with other modules & numpy...
From 1d5ea424f4ef502e84fcd300b57f9f9e8360957f Mon Sep 17 00:00:00 2001
From: Padraig Gleeson
Date: Wed, 29 Apr 2026 18:59:23 +0100
Subject: [PATCH 4/4] Updated precommit/black
---
.pre-commit-config.yaml | 4 ++--
src/modelspec/base_types.py | 32 ++++++++++++++++++++------------
src/modelspec/utils.py | 4 ++--
3 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index afa9865..de0e3d9 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -6,7 +6,7 @@ repos:
# - id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v3.4.0
+ rev: v6.0.0
hooks:
- id: check-added-large-files
args: ['--maxkb=800']
@@ -46,6 +46,6 @@ repos:
# files: src
- repo: https://github.com/psf/black
- rev: 22.3.0
+ rev: 24.10.0
hooks:
- id: black
diff --git a/src/modelspec/base_types.py b/src/modelspec/base_types.py
index 9b31e9c..7241375 100644
--- a/src/modelspec/base_types.py
+++ b/src/modelspec/base_types.py
@@ -837,9 +837,11 @@ def insert_links(text, format=MARKDOWN_FORMAT):
doc_string += (
"\n \n | {} | \n {} | ".format(
f,
- f'{type_str}'
- if referencable
- else type_str,
+ (
+ f'{type_str}'
+ if referencable
+ else type_str
+ ),
)
)
doc_string += "\n %s | \n
\n\n" % (
@@ -849,9 +851,11 @@ def insert_links(text, format=MARKDOWN_FORMAT):
elif format == RST_FORMAT:
n = "**%s**" % f
t = "{}".format(
- rst_url_format % (type_, "#" + type_str.lower())
- if referencable
- else type_str,
+ (
+ rst_url_format % (type_, "#" + type_str.lower())
+ if referencable
+ else type_str
+ ),
)
d = "%s" % (insert_links(description, format=RST_FORMAT))
table_info.append([n, t, d])
@@ -898,9 +902,11 @@ def insert_links(text, format=MARKDOWN_FORMAT):
doc_string += (
"\n \n | {} | \n {} | ".format(
c,
- f'{type_str}'
- if referencable
- else type_str,
+ (
+ f'{type_str}'
+ if referencable
+ else type_str
+ ),
)
)
doc_string += "\n %s | \n
\n\n" % (
@@ -910,9 +916,11 @@ def insert_links(text, format=MARKDOWN_FORMAT):
elif format == RST_FORMAT:
n = "**%s**" % c
t = "{}".format(
- rst_url_format % (type_str, "#" + type_str.lower())
- if referencable
- else type_str,
+ (
+ rst_url_format % (type_str, "#" + type_str.lower())
+ if referencable
+ else type_str
+ ),
)
d = "%s" % (insert_links(description, format=RST_FORMAT))
table_info.append([n, t, d])
diff --git a/src/modelspec/utils.py b/src/modelspec/utils.py
index b6c6808..b4cab16 100644
--- a/src/modelspec/utils.py
+++ b/src/modelspec/utils.py
@@ -296,8 +296,8 @@ def build_xml_element(data, parent=None):
def ascii_encode_dict(data):
- ascii_encode = (
- lambda x: x.encode("ascii")
+ ascii_encode = lambda x: (
+ x.encode("ascii")
if (sys.version_info[0] == 2 and isinstance(x, unicode))
else x
)