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
261 stars 38 forks source link

feature: Merge value when attribute is first annotated then assigned #241

Open pawamoy opened 3 months ago

pawamoy commented 3 months ago

Is your feature request related to a problem? Please describe.

In the following example:

dataclass_opts: dict[str, bool]
if sys.version_info >= (3, 10):
    dataclass_opts = {"slots": True}
else:
    dataclass_opts = {}

...the value of dataclass_opt will be None.

Describe the solution you'd like

Should we visit the if nodes instead and merge the assigned value to the previously registered annotated-only attribute?

Describe alternatives you've considered

/

Additional context

In could help value inference in #240.