Bases: Read
Class for external variable reads (File / Database).
Attributes:
Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
| @dataclass
class FileRead(Read):
"""Class for external variable reads (File / Database).
Attributes
----------
source :
The source of the read.
origin :
The origin of the read.
"""
source: Expression
origin: Symbol | NodeID | None = field(default=None)
def __hash__(self) -> int:
return hash(str(self))
def __str__(self) -> str:
if isinstance(self.source, Expression):
return f"{self.__class__.__name__}: {self.source.__str__()}"
return f"{self.__class__.__name__}: UNKNOWN EXPRESSION"
def to_dict(self) -> dict[str, Any]:
origin = (
self.origin.id if isinstance(self.origin, Symbol) else (self.origin if self.origin is not None else None)
)
return {
"origin": f"{origin}",
"reason": f"{self.source.__str__()}",
}
|
origin: Symbol | NodeID | None = field(default=None)
class-attribute
instance-attribute
source: Expression
instance-attribute
__hash__()
Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
| def __hash__(self) -> int:
return hash(str(self))
|
__init__(source, origin=None)
__str__()
Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
| def __str__(self) -> str:
if isinstance(self.source, Expression):
return f"{self.__class__.__name__}: {self.source.__str__()}"
return f"{self.__class__.__name__}: UNKNOWN EXPRESSION"
|
to_dict()
Source code in src/library_analyzer/processing/api/purity_analysis/model/_purity.py
| def to_dict(self) -> dict[str, Any]:
origin = (
self.origin.id if isinstance(self.origin, Symbol) else (self.origin if self.origin is not None else None)
)
return {
"origin": f"{origin}",
"reason": f"{self.source.__str__()}",
}
|