logoalt Hacker News

halfcattoday at 12:11 AM1 replyview on HN

Static analysis will never be fully robust in Python. As a simple example, you can define a function that only exists at runtime, so even in principle it wouldn’t be possible to type check that statically, or even know what the call path of the functions is, without actually running the code in trace/profiler mode.

You probably want something like pydantic’s @validate_call decorator.


Replies

tomjakubowskitoday at 1:45 AM

> you can define a function that only exists at runtime, so even in principle it wouldn’t be possible to type check that statically

Can you say more, maybe with with an example, about a function which can't be typed? Are you talking about generating bytecode at runtime, defining functions with lambda expressions, or something else?