Skip to main content

Questions tagged [type-hinting]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer

Postel’s law implementation with number.Complex as example [closed]

I’m trying to implement, for educational purposes only, an example of the Postel’s law on a demonstrative function. This function is not for production code, it’s for pedagogical purposes only and ...
Dorian Turba's user avatar
3 votes
1 answer

Randomly rotate an image through right angles

I'm new to Python, and coming from Typescript, I tried to include types, but it's not obvious sometimes. Currently this is the way I type objects: Write own simple types Import type from a library ...
Minsky's user avatar
  • 249
0 votes
1 answer

Type hints and expected types

I'm unsure if this question belongs on Code Review or Stack Overflow. Another developer told me that I should consider adding type hints to my open source project WordHoard. I have never used type ...
Life is complex's user avatar
2 votes
0 answers

A Haskell-style "maybe" type in Python, version 2

I have decided on a preferred solution to my question A maybe type in Python. Which implementation is best?, and have expanded it to be more ergonomic. I have implemented a host of utility functions (...
schuelermine's user avatar
0 votes
1 answer

Subscriptable Type Hinting and Instance Checks

Background The typing module supports subscriptable types. Here is an example use case: ...
The Thonnu's user avatar
3 votes
0 answers

Build the Mountain Car Environment using coupled inheritance and type annotations

This code builds the environment for the standard Mountain Car Problem of reinforcement learning. I'm using Python 3.9 with PyCharm and I'm wishing to use type annotations throughout. I'm trying to ...
Robin Carter's user avatar
2 votes
1 answer

Decorator for forward type hint resolution

Background I frequently develop ORM libraries using the peewee framework. On one particularly large ORM library, representing a proprietary data format, I have a lot of coupled ORM models representing ...
Richard Neumann's user avatar