Skip to content

Commit a4ce6fb

Browse files
committed
Workaround single locations test
1 parent f50fd18 commit a4ce6fb

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

packages/griffelib/src/griffe/__init__.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -593,21 +593,25 @@
593593
"vtree",
594594
]
595595

596+
# Re-export griffecli for backward compatibility.
596597
try:
597-
from griffecli import DEFAULT_LOG_LEVEL, check, dump, get_parser, main # noqa: F401
598+
from griffecli import *
599+
from griffecli import __all__ as __cli_all__
598600
except ImportError:
599-
_CLI_MISSING_FEATURES = {
601+
# Keep this in sync with the exported members of griffecli.
602+
_MISSING_FROM_GRIFFECLI = {
600603
"DEFAULT_LOG_LEVEL",
601604
"check",
602605
"dump",
603606
"get_parser",
604607
"main",
605608
}
606-
else:
607-
_CLI_MISSING_FEATURES = set()
608-
609609

610-
def __getattr__(attr: str) -> object:
611-
if attr in _CLI_MISSING_FEATURES:
612-
raise ImportError(f"Please install `griffecli` to use {'griffe.' + attr!r}")
613-
raise AttributeError(attr)
610+
def __getattr__(attr: str) -> object:
611+
if attr in _MISSING_FROM_GRIFFECLI:
612+
raise ImportError(f"Please install `griffecli` to use {'griffe.' + attr!r}")
613+
raise AttributeError(attr)
614+
else:
615+
__all__ += __cli_all__
616+
# Ignore this namespace in internal API tests.
617+
_SINGLE_LOCATIONS_IGNORE = set(__cli_all__)

tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _public_path(obj: griffe.Object | griffe.Alias) -> bool:
143143

144144
public_api = _get_public_api(tested_module)
145145
multiple_locations = {}
146-
for obj_name in tested_module.__all__:
146+
for obj_name in set(tested_module.__all__) - getattr(tested_module, "_SINGLE_LOCATIONS_IGNORE", set()):
147147
obj = public_api[obj_name]
148148
if obj.aliases and (
149149
public_aliases := [path for path, alias in obj.aliases.items() if path != obj.path and _public_path(alias)]

0 commit comments

Comments
 (0)