Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Fix get config fields for Pytext documentation
Browse files Browse the repository at this point in the history
Summary: pytext gen-default-config was failing with recursion, turns out getting "Config" attribute isn't visible with dir(obj) but is with hasattr(obj, "Config"). Also tiny fix for a null "include_dirs" when trying to run the output config.

Reviewed By: hudeven

Differential Revision: D19397681

fbshipit-source-id: bd78da808e32c43019154aa1895179dbc6252bf7
  • Loading branch information
Michael Wu authored and facebook-github-bot committed Jan 15, 2020
1 parent 30b281c commit 8dfd39e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pytext/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def load_config():
eprint("No config file specified, reading from stdin")
config = json.load(sys.stdin)
# before parsing the config, include the custom components
for path in config.get("include_dirs", []):
for path in config.get("include_dirs", None) or []:
add_include(path.rstrip("/"))
context.obj.config = parse_config(config)
return context.obj.config
Expand Down
2 changes: 1 addition & 1 deletion pytext/utils/documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

def get_class_members_recursive(obj):
"""Find all the field names for a given class and their default value."""
ret = dict(vars(obj.Config if "Config" in dir(obj) else obj))
ret = dict(vars(obj.Config if hasattr(obj, "Config") else obj))
for b in getattr(obj, "__bases__", []):
# Only pytext configs.
# Exclude Module because it adds load_path and save_path.
Expand Down

0 comments on commit 8dfd39e

Please sign in to comment.