Skip to content

Commit

Permalink
Remove casts which don't work correctly because MyPy doesn't inherit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Kami committed Mar 1, 2020
1 parent 58ad075 commit 3d7bb46
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions example_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@

from typing import Type, cast

ec2_cls = get_driver(Provider.EC2)
rackspace_cls = get_driver(Provider.RACKSPACE)

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

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

0 comments on commit 3d7bb46

Please sign in to comment.