mkdocstrings / griffe

Signatures for entire Python programs. Extract the structure, the frame, the skeleton of your project, to generate API documentation or find breaking changes in your API.
https://mkdocstrings.github.io/griffe
ISC License
267 stars 38 forks source link

API checks: Don't report type-guarded objects #217

Closed pawamoy closed 7 months ago

pawamoy commented 8 months ago

Describe the bug A removed type-guarded item will be reported. It should not, since it's not available at runtime.

gpuligundla commented 7 months ago

Hi, could you please describe more about the bug, with current behaviour and expected behaviour

pawamoy commented 7 months ago

Sure, sorry for the low quality report 😅

For example with:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from thing import stuff

If you remove the import under the type checking condition, Griffe will report that stuff was removed from the module.

But this is wrong: stuff was never available at runtime, and therefore should not be reported.

Griffe already detects such "type-guarded" objects, and sets runtime=False on them. We could use this runtime attribute to prevent reporting their removal.

gpuligundla commented 7 months ago

Hi @pawamoy, I guess the current version of griffe doesn't report this error. I tried to test it by passing it to find_breaking_changes(). it checks the runtime and ignores reporting.

or am I in the wrong direction? help me to understand it

pawamoy commented 7 months ago

Well, it seems I cannot reproduce the issue described here :thinking: I noticed a few times typing-related objects being reported, and I suppose I wrongly thought they were type-guarded while they were not :thinking: Sorry that you wasted time on this :bow: Lets close. I'll reopen if I find a reproducible example.