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

Simplify Model __new__ and metaclass #7473

Merged
merged 14 commits into from
Oct 10, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix type of UNSET in type definition
UNSET is the instance of the _UnsetType type.
We should be typing the latter here.
  • Loading branch information
thomasaarholt committed Oct 10, 2024
commit e2cefc3e4aff2cff5cf0324f52640e2c29bb0daa
5 changes: 3 additions & 2 deletions pymc/model/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
VarName,
WithMemoization,
_add_future_warning_tag,
_UnsetType,
get_transformed_name,
get_value_vars_from_user_vars,
get_var_name,
Expand Down Expand Up @@ -507,7 +508,7 @@ def __exit__(self, exc_type: None, exc_val: None, exc_tb: None) -> None:
"""Exit the context manager."""
_ = MODEL_MANAGER.active_contexts.pop()

def __new__(cls, *args, model: Literal[UNSET] | None | Model = UNSET, **kwargs):
def __new__(cls, *args, model: _UnsetType | None | Model = UNSET, **kwargs):
# resolves the parent instance
instance = super().__new__(cls)
if model is UNSET:
Expand All @@ -529,7 +530,7 @@ def __init__(
check_bounds=True,
*,
coords_mutable=None,
model: Literal[UNSET] | None | Model = UNSET,
model: _UnsetType | None | Model = UNSET,
):
del model # used in __new__ to define the parent of this model
self.name = self._validate_name(name)
Expand Down