This PR proposes to eliminate the Package class, which superclasses PackageScanner and ProjectScanner.
Reasons to do this:
There is no context in which a PackageScanner and a ProjectScanner can be used interchangeably without a great deal of difficulty. These classes have only one common method, scan_local(), that expect different kinds (as opposed to types) of arguments: a path to a local package directory or archive for PackageScanner versus a path to a requirements.txt file for ProjectScanner
It seems the only purpose of Package is to give scanner.get_scanner() a definite, non-union return type. However, we end up paying elsewhere for this simplicity, namely via the explicit cast in cli._scan() needed only to satisfy the type checker, so it's not clear we gain anything from it. This PR splits get_scanner() into two functions to eliminate the cast
This PR proposes to eliminate the
Package
class, which superclassesPackageScanner
andProjectScanner
.Reasons to do this:
There is no context in which a
PackageScanner
and aProjectScanner
can be used interchangeably without a great deal of difficulty. These classes have only one common method,scan_local()
, that expect different kinds (as opposed to types) of arguments: a path to a local package directory or archive forPackageScanner
versus a path to arequirements.txt
file forProjectScanner
It seems the only purpose of
Package
is to givescanner.get_scanner()
a definite, non-union return type. However, we end up paying elsewhere for this simplicity, namely via the explicit cast incli._scan()
needed only to satisfy the type checker, so it's not clear we gain anything from it. This PR splitsget_scanner()
into two functions to eliminate the cast