Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Rework how we refine information from callable() #4343
Don't ever assume that something is not callable; basically anything
When operating on an Instance that is not clearly callable, construct
This is being posted to solicit feedback, I expect it might need some large changes.
This is a reasonable first try at this! I didn't do a detailed review yet but left some comments.
On second thought, creating a new subclass might be bit of an overkill considering that this is not a very common use case. Here's an idea about a simpler "good enough" fix:
Oops, I wish I had noticed your last comment this morning.
Pushed changes to address most of the comments. I still need to move the functions into the TypeChecker class, but I've put that off to keep the diffs easy to read.
Another way to structure this would be to return just a
Thanks for the updates! This is looking pretty good (once you refactor the
TypeChecker arguments away).
TypeInfo attributes might still need processing, though some of these are kind of unlikely to have an effect so just adding a TODO comment may suffice:
is_abstract(say, if one does
is_protocol(not sure about this)
runtime_protocol(if one does
isinstance(y, type(x))which would be pretty perverse)
is_enum(if it's an enum)
_promote(you can test by doing
x: intand checking that the narrowed type is compatible with
I think the