Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

literal schema_name #337

Merged
merged 7 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
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="^(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
Loading