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

fix: Don't return class variables as parameters of dataclasses #253

Closed has2k1 closed 3 months ago

has2k1 commented 3 months ago

This PR fixes the issue where class variables are recognised as class parameters.

This definition

from dataclasses import dataclass
from typing import ClassVar

@dataclass
class Point:
    x: float
    y: float
    z: ClassVar[float] = 3

is equivalent to

class Point:
    z: float = 3

    def __init__(self, x: float, y: float):
        self.x = x
        self.y = y

The signature is Point(x, y) and neither Point(x, y, z) or Point(x, y, z=3).