Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
uses: OpenJobDescription/.github/.github/workflows/reusable_python_build.yml@mainline
with:
os: ${{ matrix.os }}
Expand Down
16 changes: 11 additions & 5 deletions src/openjd/model/_internal/_variable_reference_validation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

import sys
from collections import defaultdict
import typing
from typing import cast, Any, Optional, Type, Literal, Union
Expand All @@ -9,8 +10,11 @@
from pydantic_core import InitErrorDetails
from pydantic.fields import FieldInfo, ModelPrivateAttr

# Workaround for Python 3.9 where issubclass raises an error "TypeError: issubclass() arg 1 must be a class"
from pydantic.v1.utils import lenient_issubclass
if sys.version_info >= (3, 10):
_issubclass_for_pydantic = issubclass
else:
# Workaround for Python 3.9 where issubclass raises an error "TypeError: issubclass() arg 1 must be a class"
from pydantic.v1.utils import lenient_issubclass as _issubclass_for_pydantic

from .._types import OpenJDModel, ResolutionScope, ModelParsingContextInterface
from .._format_strings import FormatString, FormatStringError
Expand Down Expand Up @@ -307,7 +311,7 @@ def _validate_model_template_variable_references(
else:
return errors

if isclass(model) and lenient_issubclass(model, FormatString):
if isclass(model) and _issubclass_for_pydantic(model, FormatString):
if not isinstance(value, FormatString):
if context is None:
raise ValueError(
Expand All @@ -321,7 +325,9 @@ def _validate_model_template_variable_references(
return _check_format_string(value, current_scope, symbols, loc, context=context)

# Return an empty error list if it's not an OpenJDModel, or if it's not a dict
if not (isclass(model) and lenient_issubclass(model, OpenJDModel) and isinstance(value, dict)):
if not (
isclass(model) and _issubclass_for_pydantic(model, OpenJDModel) and isinstance(value, dict)
):
return []

# Does this cls change the variable reference scope for itself and its children? If so, then update
Expand Down Expand Up @@ -557,7 +563,7 @@ def _collect_variable_definitions( # noqa: C901 (suppress: too complex)
return {"__export__": ScopedSymtabs()}

# Anything except for an OpenJDModel returns an empty result
if not isclass(model) or not lenient_issubclass(model, OpenJDModel):
if not isclass(model) or not _issubclass_for_pydantic(model, OpenJDModel):
return {"__export__": ScopedSymtabs()}

# If the model has no exported variable definitions, prune it
Expand Down