Skip to content

Union of hashables is not hashable #8268

Answered by erictraut
JanEricNitschke asked this question in Q&A
Discussion options

You must be logged in to vote

You could use a type variable with an upper bound of Hashable.

import pandas as pd
from typing import Hashable, Mapping

def func[T: Hashable](a: Mapping[T, pd.DataFrame]) -> None: ...

value = {1: pd.DataFrame(), "a": pd.DataFrame()}
func(value)

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@JanEricNitschke
Comment options

@erictraut
Comment options

Answer selected by JanEricNitschke
@JanEricNitschke
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants