@@ -1193,14 +1193,31 @@ def as_dict(self, *, full: bool = False, **kwargs: Any) -> dict[str, Any]:
11931193 base : dict [str , Any ] = {
11941194 "kind" : self .kind ,
11951195 "name" : self .name ,
1196- "public" : self .public ,
1197- "exports" : self .exports and [str (export ) for export in self .exports ],
1198- "imports" : self .imports ,
11991196 "runtime" : self .runtime ,
1200- "deprecated" : self .deprecated ,
1201- # TODO: Include `self.extra`?
12021197 }
12031198
1199+ if self .public is not None :
1200+ base ["public" ] = self .public
1201+ if self .exports is not None :
1202+ base ["exports" ] = [str (export ) for export in self .exports ]
1203+ if self .imports :
1204+ base ["imports" ] = self .imports
1205+ if self .deprecated is not None :
1206+ base ["deprecated" ] = self .deprecated
1207+ if self .lineno is not None :
1208+ base ["lineno" ] = self .lineno
1209+ if self .endlineno is not None :
1210+ base ["endlineno" ] = self .endlineno
1211+ if self .docstring :
1212+ base ["docstring" ] = self .docstring
1213+ if self .type_parameters :
1214+ base ["type_parameters" ] = [type_param .as_dict (** kwargs ) for type_param in self .type_parameters ]
1215+ if self .labels :
1216+ base ["labels" ] = self .labels
1217+ if self .members :
1218+ base ["members" ] = {name : member .as_dict (full = full , ** kwargs ) for name , member in self .members .items ()}
1219+ # TODO: Include `self.extra`?
1220+
12041221 if full :
12051222 base .update (
12061223 {
@@ -1216,7 +1233,6 @@ def as_dict(self, *, full: bool = False, **kwargs: Any) -> dict[str, Any]:
12161233 "is_imported" : self .is_imported ,
12171234 "is_exported" : self .is_exported ,
12181235 "is_wildcard_exposed" : self .is_wildcard_exposed ,
1219- "is_inherited" : self .inherited ,
12201236 # TODO: Add these properties?
12211237 # "is_alias": self.is_alias,
12221238 # "is_collection": self.is_collection,
@@ -1235,18 +1251,6 @@ def as_dict(self, *, full: bool = False, **kwargs: Any) -> dict[str, Any]:
12351251 },
12361252 )
12371253
1238- if self .lineno is not None :
1239- base ["lineno" ] = self .lineno
1240- if self .endlineno is not None :
1241- base ["endlineno" ] = self .endlineno
1242- if self .docstring :
1243- base ["docstring" ] = self .docstring
1244- if self .type_parameters :
1245- base ["type_parameters" ] = [type_param .as_dict (** kwargs ) for type_param in self .type_parameters ]
1246-
1247- base ["labels" ] = self .labels
1248- base ["members" ] = {name : member .as_dict (full = full , ** kwargs ) for name , member in self .members .items ()}
1249-
12501254 return base
12511255
12521256
@@ -2077,19 +2081,23 @@ def as_dict(self, *, full: bool = False, **kwargs: Any) -> dict[str, Any]: # no
20772081 "kind" : Kind .ALIAS ,
20782082 "name" : self .name ,
20792083 "target_path" : self .target_path ,
2080- "public" : self .public ,
20812084 "runtime" : self .runtime ,
20822085 "inherited" : self .inherited ,
2083- "deprecated" : self .deprecated ,
20842086 }
20852087
2088+ if self .public is not None :
2089+ base ["public" ] = self .public
2090+ if self .deprecated is not None :
2091+ base ["deprecated" ] = self .deprecated
2092+ if self .alias_lineno :
2093+ base ["lineno" ] = self .alias_lineno
2094+ if self .alias_endlineno :
2095+ base ["endlineno" ] = self .alias_endlineno
2096+
20862097 if full :
20872098 base .update (
20882099 {
20892100 "path" : self .path ,
2090- "filepath" : self .filepath ,
2091- "relative_filepath" : self .relative_filepath ,
2092- "relative_package_filepath" : self .relative_package_filepath ,
20932101 "is_public" : self .is_public ,
20942102 "is_deprecated" : self .is_deprecated ,
20952103 "is_private" : self .is_private ,
@@ -2098,30 +2106,9 @@ def as_dict(self, *, full: bool = False, **kwargs: Any) -> dict[str, Any]: # no
20982106 "is_imported" : self .is_imported ,
20992107 "is_exported" : self .is_exported ,
21002108 "is_wildcard_exposed" : self .is_wildcard_exposed ,
2101- "is_inherited" : self .inherited ,
2102- # TODO: Add these properties?
2103- # "is_alias": self.is_alias,
2104- # "is_collection": self.is_collection,
2105- # "is_module": self.is_module,
2106- # "is_class": self.is_class,
2107- # "is_function": self.is_function,
2108- # "is_attribute": self.is_attribute,
2109- # "is_type_alias": self.is_type_alias,
2110- # "is_init_module": self.is_init_module,
2111- # "is_package": self.is_package,
2112- # "is_subpackage": self.is_subpackage,
2113- # "is_namespace_package": self.is_namespace_package,
2114- # "is_namespace_subpackage": self.is_namespace_subpackage,
2115- # "has_docstring": self.has_docstring,
2116- # "has_docstrings": self.has_docstrings,
2117- }
2109+ },
21182110 )
21192111
2120- if self .alias_lineno :
2121- base ["lineno" ] = self .alias_lineno
2122- if self .alias_endlineno :
2123- base ["endlineno" ] = self .alias_endlineno
2124-
21252112 return base
21262113
21272114
0 commit comments