Skip to content

Commit

Permalink
Resolves subscripted generics instance check issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Eleff committed Aug 21, 2024
1 parent e1edb56 commit 4f7b76c
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions assemblit/_app/_generic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _env():
ASSEMBLIT_DIR : `Union[str, os.PathLike]`
The local filesystem folder to mount to the docker container.
ASSEMBLIT_CLIENT_PORT : Optional[`int`] = 8501
ASSEMBLIT_CLIENT_PORT : `Optional[int]` = 8501
The client port of the `assemblit` web-application within the docker container.
"""

Expand Down Expand Up @@ -75,19 +75,20 @@ def __post_init__(self):

# Validate types
for variable in fields(self):
value = getattr(self, variable.name)
if not isinstance(value, variable.type):
raise ValueError(
'Invalid dtype {%s} for {%s}. Expected {%s}.' % (
type(value).__name__,
variable.name,
(variable.type).__name__
if variable.name not in ['ASSEMBLIT_DIR']: # Avoid type-checking `ASSEMBLIT_DIR` due to Python 3.8 and 3.9 behavior
value = getattr(self, variable.name)
if not isinstance(value, variable.type):
raise ValueError(
'Invalid dtype {%s} for {%s}. Expected {%s}.' % (
type(value).__name__,
variable.name,
(variable.type).__name__
)
)
)

# Convert relative directory paths to absoluate paths
if variable.name in ['ASSEMBLIT_DIR']:
setattr(self, variable.name, os.path.abspath(getattr(self, variable.name)))
# Convert relative directory paths to absoluate paths
if variable.name in ['ASSEMBLIT_DIR']:
setattr(self, variable.name, os.path.abspath(getattr(self, variable.name)))

def to_dict(self) -> dict:
""" Returns the environment variables and values as a dictionary. """
Expand Down

0 comments on commit 4f7b76c

Please sign in to comment.