Skip to content

Commit

Permalink
use qualname for all naming of PluginAPITypeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
lilatomic committed Apr 28, 2024
1 parent 6b7dcf6 commit 96ddd19
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/python/pants/help/help_info_extracter.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ class PluginAPITypeInfo:
consumed_by_rules: tuple[str, ...]
used_in_rules: tuple[str, ...]

@property
def fully_qualified_name(self) -> str:
return f"{self.module}.{self.name}"

@classmethod
def create(
cls, api_type: type, rules: Sequence[Rule | UnionRule], **kwargs
Expand All @@ -345,7 +349,7 @@ def create(
task_rules = [rule for rule in rules if isinstance(rule, TaskRule)]

return cls(
name=api_type.__name__,
name=api_type.__qualname__,
module=api_type.__module__,
documentation=maybe_cleandoc(api_type.__doc__),
is_union=is_union(api_type),
Expand Down Expand Up @@ -842,13 +846,12 @@ def get_api_type_info(api_type: type) -> PluginAPITypeInfo:
)

infos: dict[str, PluginAPITypeInfo] = {}
for api_type in sorted(all_types, key=attrgetter("__name__")):
api_type_name = f"{api_type.__module__}.{api_type.__qualname__}"
for api_type in sorted(all_types, key=attrgetter("__qualname__")):
api_type_info = get_api_type_info(api_type)
if api_type_name in infos:
infos[api_type_name] = infos[api_type_name].merged_with(api_type_info)
if api_type_info.fully_qualified_name in infos:
infos[api_type_info.fully_qualified_name] = infos[api_type_info.fully_qualified_name].merged_with(api_type_info)
else:
infos[api_type_name] = api_type_info
infos[api_type_info.fully_qualified_name] = api_type_info

return FrozenDict(infos)

Expand Down

0 comments on commit 96ddd19

Please sign in to comment.