I have e.g. a utils.py file containing helper functions that I want to type hint. utils.py doesnt need any non standard lib imports but receives and returns non-standard types, so I have to import the modules into utils.py just to be able to add the type hints – is that right / normal practise? I know in Python I can import the same lib from multiple files in the same project and it only actually imports each once, so its not a real problem, just seems like a lot of “unecessary” imports and wondering if there is a different or more preferred way to get types?
submitted by /u/heyzooschristos
[link] [comments]
r/learnpython I have e.g. a utils.py file containing helper functions that I want to type hint. utils.py doesnt need any non standard lib imports but receives and returns non-standard types, so I have to import the modules into utils.py just to be able to add the type hints – is that right / normal practise? I know in Python I can import the same lib from multiple files in the same project and it only actually imports each once, so its not a real problem, just seems like a lot of “unecessary” imports and wondering if there is a different or more preferred way to get types? submitted by /u/heyzooschristos [link] [comments]
I have e.g. a utils.py file containing helper functions that I want to type hint. utils.py doesnt need any non standard lib imports but receives and returns non-standard types, so I have to import the modules into utils.py just to be able to add the type hints – is that right / normal practise? I know in Python I can import the same lib from multiple files in the same project and it only actually imports each once, so its not a real problem, just seems like a lot of “unecessary” imports and wondering if there is a different or more preferred way to get types?
submitted by /u/heyzooschristos
[link] [comments]