Skip to content

Commit

Permalink
Cleaning up logic for excluding certain default mangled methods
Browse files Browse the repository at this point in the history
  • Loading branch information
KaylaHood committed Nov 13, 2022
1 parent cc016b6 commit 5161681
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions generate_stub.py
Expand Up @@ -9,8 +9,7 @@
import faker.proxy

BUILTIN_MODULES_TO_IGNORE = ["builtins"]
GENERIC_MANGLE_TYPES_TO_IGNORE = ["builtin_function_or_method", "wrapper_descriptor",
"method_descriptor", "mappingproxy", "getset_descriptor"]
GENERIC_MANGLE_TYPES_TO_IGNORE = ["builtin_function_or_method", "mappingproxy"]


def get_module_and_member(cls, locale = None) -> Tuple[str, str]:
Expand Down Expand Up @@ -48,7 +47,7 @@ def __init__(self, cls: type, funcs: Dict[str, Any], vars: Dict[str, Any]):
seen_funcs = seen_funcs.union(self.funcs.keys())

self.vars = vars
for var_name in seen_vars:
for var_name in seen_vars.union(seen_funcs):
self.vars.pop(var_name, None)
seen_vars = seen_vars.union(self.vars.keys())

Expand All @@ -63,10 +62,11 @@ def get_member_functions_and_variables(cls: object, include_mangled: bool = Fals
attr = getattr(cls, name, None)
if attr is not None and (inspect.isfunction(attr) or inspect.ismethod(attr)):
funcs[name] = value
else:
if (include_mangled and name.startswith("__")
and type(value).__name__ in GENERIC_MANGLE_TYPES_TO_IGNORE):
continue
elif inspect.isgetsetdescriptor(attr) or inspect.ismethoddescriptor(attr):
# I haven't implemented logic
# for generating descriptor signatures yet
continue
elif not include_mangled or type(value).__name__ not in GENERIC_MANGLE_TYPES_TO_IGNORE:
vars[name] = value

return UniqueMemberFunctionsAndVariables(cls, funcs, vars)
Expand Down

0 comments on commit 5161681

Please sign in to comment.