Skip to content
Advertisement

Tag: type-hinting

Pythonic type hints with pandas?

Let’s take a simple function that takes a str and returns a dataframe: What is the recommended pythonic way of adding type hints to this function? If I ask python for the type of a DataFrame it returns pandas.core.frame.DataFrame. The following won’t work though, as it’ll tell me that pandas is not defined. Answer Why not just use pd.DataFrame? Result

Python type hinting without cyclic imports

I’m trying to split my huge class into two; well, basically into the “main” class and a mixin with additional functions, like so: main.py file: mymixin.py file: Now, while this works just fine, the type hint in MyMixin.func2 of course can’t work. I can’t import main.py, because I’d get a cyclic import and without the hint, my editor (PyCharm) can’t

Correct way use type hints / generics to describe arguments of type class (“type”)

This appears to be similar to Type Hinting: Argument Of Type Class, however, the accepted answer there does not actually answer my question, so perhaps the question was expressed incorrectly (?) I have a serialization/deserialization framework that would benefit greatly from [IDE-supported] type hinting. The API looks something like this: The serialization method is fine, but deserialize type hinting is

Advertisement