sourcenouveau,
@sourcenouveau@fosstodon.org avatar

Does mypy not do type inference when you use functions from other modules? That can't be right...

If I have:

modabc.py

def abc() -> str:  
 return "abc"  

modxyz.py

from modabc import abc

def xyz() -> str:  
 x = abc()  
 return x  

I get error: Returning Any from function declared to return "str".

I would prefer not to annotate the local variable. How come mypy isn't checking the annotations from modabc?

_chrismay,
@_chrismay@fosstodon.org avatar

@sourcenouveau Something else is going on. I've done a similar thing many times, tested the code you mentioned above, and mypy is happy.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • python
  • DreamBathrooms
  • ngwrru68w68
  • InstantRegret
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • tacticalgear
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • ethstaker
  • JUstTest
  • GTA5RPClips
  • modclub
  • tester
  • Leos
  • osvaldo12
  • cisconetworking
  • everett
  • cubers
  • normalnudes
  • anitta
  • megavids
  • provamag3
  • lostlight
  • All magazines