79585245

Date: 2025-04-21 20:07:29
Score: 2.5
Natty:
Report link

As far as I know, Python’s type system doesn’t let you write an overload that only applies when the argument isn’t a literal. There's just no concept of a "non-literal" type as a separate category.

You could handle the type checks manually at runtime, or split the function into a few separate ones depending on the case.

Unfortunately, I don't know of any way to express "this overload is for non-literals only" in a cleaner way :(

Reasons:
  • Blacklisted phrase (1): :(
  • No code block (0.5):
  • Low reputation (1):
Posted by: Viktor Sbruev