Skip to content

cast is used in internal.io_handling but not imported if typing is not present #166

@mattsb42-aws

Description

@mattsb42-aws

As with all of our other modules, in internal.io_handling we catch all imports from typing because of issues with CPython 3.5.0 and 3.5.1.

try: # Python 3.5.0 and 3.5.1 have incompatible typing modules
from typing import cast, Dict, IO, List, Type, Union # noqa pylint: disable=unused-import
from aws_encryption_sdk_cli.internal.mypy_types import SOURCE, STREAM_KWARGS # noqa pylint: disable=unused-import
except ImportError: # pragma: no cover
# We only actually need these imports when running the mypy checks
pass

In 1.1.6, we removed the dependency on typingbecause I had thought that we only used imports from typing in our Python-2-compatible typehints.

However, in internal.io_handling, we use typing.cast.

stream_args=stream_args, source=cast(IO, source), destination_writer=destination_writer

This only does anything when the file is being processed by mypy or a similar analyzer, so a quick fix for this is for us to just assign a no-op lambda to cast in the import catch statement.

However, I am concerned that our CI did not catch this...I would like to find out what happened there too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions