Skip to content

RuntimeError: Not implemented mypy.types.TypeGuardedType #19412

Closed

Description

@gopidesupavan

Bug Report
Getting error RuntimeError: ('Not implemented', <class 'mypy.types.TypeGuardedType'>)

(A clear and concise description of what the bug is.)

To Reproduce
Interestingly i cant reproduce with the below one.

from typing import Any, TextIO, TypeAlias, TypeVar, TYPE_CHECKING,
if TYPE_CHECKING:
    from airflow.typing_compat import TypeGuard
V1EnvVar = TypeVar("V1EnvVar")
Redactable: TypeAlias = str | V1EnvVar | dict[Any, Any] | tuple[Any, ...] | list[Any]
@cache
def _get_v1_env_var_type() -> type:
    try:
        from kubernetes.client import V1EnvVar
    except ImportError:
        return type("V1EnvVar", (), {})
    return V1EnvVar


def _is_v1_env_var(v: Any) -> TypeGuard[V1EnvVar]:
    return isinstance(v, _get_v1_env_var_type())

But when i execute the https://github.com/apache/airflow/blob/main/task-sdk/src/airflow/sdk/execution_time/secrets_masker.py am getting the runtime error.

Traceback (most recent call last):
  File "/usr/local/bin/mypy", line 10, in <module>
    sys.exit(console_entry())
  File "mypy/build.py", line 2062, in wrap_context
  File "mypy/build.py", line 2391, in finish_passes
  File "mypy/build.py", line 2424, in _patch_indirect_dependencies
  File "mypy/indirection.py", line 35, in find_modules
  File "mypy/indirection.py", line 46, in _visit
  File "mypy/types.py", line 276, in accept
RuntimeError: ('Not implemented', <class 'mypy.types.TypeGuardedType'>)
task-sdk/src/airflow/sdk/execution_time/secrets_masker.py: : note: use --pdb to drop into pdb

Expected Behavior

Actual Behavior

Your Environment

  • Mypy version used: 1.16.1
  • Mypy command-line flags: mypy task-sdk/src/airflow/sdk/execution_time/secrets_masker.py
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.10

Activity

  1. added and removed
    bugmypy got something wrong
    on Jul 9, 2025
  2. sterliakov commented on Jul 10, 2025

    @sterliakov
    Collaborator

    This passes on current master and bisects to the merge commit of #19183.

    @ilevkivskyi could you please take a look? I feel like that PR only fixed this issue accidentally and does not resolve the root cause, but would love to be proven wrong!

  3. hauntsaninja commented on Jul 10, 2025

    @hauntsaninja
    Collaborator

    Is probably same as this comment: #19183 (comment)

  4. ilevkivskyi commented on Jul 10, 2025

    @ilevkivskyi
    Member

    Yeah, that is a valid fix for this case. No need to keep this open.

  5. gopidesupavan commented on Jul 10, 2025

    @gopidesupavan
    Author

    Thanks all, executed on main branch the issue is fixed. its fine now. :)

  6. gopidesupavan commented on Jul 10, 2025

    @gopidesupavan
    Author

    so this is available in 1.17?

  7. hauntsaninja commented on Jul 10, 2025

    @hauntsaninja
    Collaborator

    Yes, will be part of 1.17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions