Skip to content

Commit 3d7bb46

Browse files
committed
Remove casts which don't work correctly because MyPy doesn't inherit
parent class signature for methods which are overriden in the subclass. This means we sadly need to rely on annotations from the base class. See python/mypy#3903 for details.
1 parent 58ad075 commit 3d7bb46

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

example_compute.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,8 @@
2121

2222
from typing import Type, cast
2323

24-
ec2_cls = get_driver(Provider.EC2)
25-
rackspace_cls = get_driver(Provider.RACKSPACE)
26-
27-
# NOTE: If you are using driver methods which are not part of the standard API,
28-
# you need to explicitly cast the driver class reference to the correct class
29-
# for type checking to work correctly
30-
EC2 = cast(Type[EC2NodeDriver], ec2_cls)
31-
Rackspace = cast(Type[RackspaceNodeDriver], rackspace_cls)
24+
EC2 = get_driver(Provider.EC2)
25+
Rackspace = get_driver(Provider.RACKSPACE)
3226

3327
drivers = [EC2('access key id', 'secret key', region='us-east-1'),
3428
Rackspace('username', 'api key', region='iad')]

0 commit comments

Comments
 (0)