Skip to content

Commit

Permalink
Drop large disclaimer, thanks to generic reimplementation
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Mar 19, 2023
1 parent 7479563 commit 9fc14ba
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/eko/quantities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,4 @@
Few related functions are also defined here.
Note
----
Unfortunately, Python has still some discrepancies between runtime classes and
type hints, so it is better not to mix dataclasses and generics.
E.g. before it was implemented::
@dataclasses.dataclass
class RunningReference(DictLike, Generic[Quantity]):
value: Quantity
scale: float
but in this way it is not possible to determine that ``RunningReference`` is
subclassing ``DictLike``, indeed::
inspect.isclass(RunningReference) # False
issubclass(RunningReference, DictLike) # raise an error, since
# RunningReference is not a class
Essentially classes can be used for type hints, but types are not all classes,
especially when they involve generics.
For this reason I prefer the less elegant dynamic generation, that seems to
preserve type hints.
"""

0 comments on commit 9fc14ba

Please sign in to comment.