data-apis / python-record-api

Inferring Python API signatures from tracing usage.
MIT License
75 stars 6 forks source link

Put types in parent modules #6

Open saulshanabrook opened 4 years ago

saulshanabrook commented 4 years ago

Currently, we list the type where an object is defined as its module. However, many libraries define types in some sub-module but only expose them in a parent module.

So instead, when recording a type, we should look in all parent modules to see if they export this same type. If so, we should use that as the module name instead of where it is created.

saulshanabrook commented 4 years ago

Actually we should do this by relying on return type of getattr on modules... If we see a downstream thing getting an attribute of a module, that will be where the class is from!