Skip to content

Commit

Permalink
literal schema_name (#337)
Browse files Browse the repository at this point in the history
* Update results.py

* Update procedures.py

* Update results.py

* Update procedures.py

* Update procedures.py

* Update results.py
  • Loading branch information
loriab authored Sep 18, 2024
1 parent 248d988 commit c14e638
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion qcelemental/models/procedures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from enum import Enum
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple

try:
from typing import Literal
except ImportError:
# remove when minimum py38
from typing_extensions import Literal

try:
from pydantic.v1 import Field, conlist, constr, validator
except ImportError: # Will also trap ModuleNotFoundError
Expand Down Expand Up @@ -58,7 +64,7 @@ class QCInputSpecification(ProtoModel):
A compute description for energy, gradient, and Hessian computations used in a geometry optimization.
"""

schema_name: constr(strip_whitespace=True, regex=qcschema_input_default) = qcschema_input_default # type: ignore
schema_name: Literal["qcschema_input"] = Field(qcschema_input_default)
schema_version: int = 1

driver: DriverEnum = Field(DriverEnum.gradient, description=str(DriverEnum.__doc__))
Expand Down
8 changes: 7 additions & 1 deletion qcelemental/models/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
from functools import partial
from typing import TYPE_CHECKING, Any, Dict, Optional, Set, Union

try:
from typing import Literal
except ImportError:
# remove when minimum py38
from typing_extensions import Literal

import numpy as np

try:
Expand Down Expand Up @@ -609,7 +615,7 @@ def __repr_args__(self) -> "ReprArgs":
class AtomicResult(AtomicInput):
r"""Results from a CMS program execution."""

schema_name: constr(strip_whitespace=True, regex=r"^(qc\_?schema_output)$") = Field( # type: ignore
schema_name: Literal["qcschema_output"] = Field(
qcschema_output_default,
description=(
f"The QCSchema specification this model conforms to. Explicitly fixed as {qcschema_output_default}."
Expand Down

0 comments on commit c14e638

Please sign in to comment.