@@ -296,12 +296,32 @@ def attributes(self) -> dict[str, Attribute]:
296
296
297
297
@property
298
298
def has_private_name (self ) -> bool :
299
- """Whether this object/alias has a private name."""
299
+ """Deprecated. Use [`is_private`][griffe.Object.is_private] instead."""
300
+ warnings .warn (
301
+ "The `has_private_name` property is deprecated. Use `is_private` instead." ,
302
+ DeprecationWarning ,
303
+ stacklevel = 2 ,
304
+ )
300
305
return self .name .startswith ("_" ) # type: ignore[attr-defined]
301
306
302
307
@property
303
308
def has_special_name (self ) -> bool :
304
- """Whether this object/alias has a special name."""
309
+ """Deprecated. Use [`is_special`][griffe.Object.is_special] instead."""
310
+ warnings .warn (
311
+ "The `has_special_name` property is deprecated. Use `is_special` instead." ,
312
+ DeprecationWarning ,
313
+ stacklevel = 2 ,
314
+ )
315
+ return self .name .startswith ("__" ) and self .name .endswith ("__" ) # type: ignore[attr-defined]
316
+
317
+ @property
318
+ def is_private (self ) -> bool :
319
+ """Whether this object/alias is private (starts with `_`) but not special."""
320
+ return self .name .startswith ("_" ) and not self .is_special # type: ignore[attr-defined]
321
+
322
+ @property
323
+ def is_special (self ) -> bool :
324
+ """Whether this object/alias is special ("dunder" attribute/method, starts and end with `__`)."""
305
325
return self .name .startswith ("__" ) and self .name .endswith ("__" ) # type: ignore[attr-defined]
306
326
307
327
@property
@@ -350,7 +370,7 @@ def is_wildcard_exposed(self) -> bool:
350
370
return False
351
371
if self .parent .exports is not None : # type: ignore[attr-defined]
352
372
return self .name in self .parent .exports # type: ignore[attr-defined]
353
- if self .has_private_name :
373
+ if self .name . startswith ( "_" ): # type: ignore[attr-defined]
354
374
return False
355
375
return self .is_alias or not self .is_module or self .name in self .parent .imports # type: ignore[attr-defined]
356
376
@@ -383,7 +403,7 @@ def is_public(self) -> bool:
383
403
# Special objects are always considered public.
384
404
# Even if we don't access them directly, they are used through different *public* means
385
405
# like instantiating classes (`__init__`), using operators (`__eq__`), etc..
386
- if self .has_private_name and not self . has_special_name :
406
+ if self .is_private :
387
407
return _False # type: ignore[return-value]
388
408
389
409
# TODO: In a future version, we will support two conventions regarding imports:
0 commit comments