https://pantsbuild.org/ logo
#development
Title
# development
h

hundreds-breakfast-49010

01/14/2021, 1:31 AM
@hundreds-father-404 is there a reason
SpecsParser.parse_spec
has return type
Union[AddressSpec, FilesystemSpec]
instead of just
Spec
?
h

hundreds-father-404

01/14/2021, 1:33 AM
Yep, because then when we do
isinstance(AddressSpec)
, MyPy knows if that's not true it would be a
FilesystemSpec
h

hundreds-breakfast-49010

01/14/2021, 1:34 AM
so mypy in general doesn't assume it knows about all subclasses of a class that might exist?
h

hundreds-father-404

01/14/2021, 1:35 AM
exactly, because it cannot do that. So we would need to do:
Copy code
if isinstance(AddressSpec):
  ...
elif isinstance(FilesystemSpec):
  ...
else:
  raise Unexpected