-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Enforce use of Args: over Attrs: in class docstrings #15404
base: master
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @smackesey and the rest of your teammates on Graphite |
dbb83ba
to
a0ae028
Compare
Deploy preview for dagster ready! Preview available at https://dagster-gm5422dvj-elementl.vercel.app Direct link to changed pages: |
a0ae028
to
47a90c4
Compare
I agree that the way that "Args" gets rendered looks a lot nicer. However, I think that "Attrs" is more representative of what we're trying to communicate, i.e. that these are the attributes of this class. I wonder if there's some way to address the rendering issues. |
Disagree that "Attrs" is more representative of what we're communicating, because the way most of our public classes are written we don't expose attributes-- we expose properties, which are documented separately. At the level of the class docstring itself, the public API we are documenting is the constructor parameters, not the attributes, which are typically private. Also, often the constructor parameters are going to differ from the attributes-- this happens whenever there is a deprecated param, but also in other cases where there is some logic in the constructor. It's clear that we need to document such deprecated constructor params but it would be incorrect to call them "attributes". Now for |
b2a509c
to
d374213
Compare
In a google search on "python properties vs attributes", most results claim that properties are a special kind of attribute. In many cases, the types that a constructor accepts will be more permissive than the class's attributes, or constructors will include deprecated parameters that get converted to canonical attributes. It's useful to have documentation for the canonical attributes because they describe what the class is, rather than just what arguments are required to construct it. |
Might be worth collecting other opinions from the team? Not a hill that I'm going to die on. |
d374213
to
d131026
Compare
47a90c4
to
2c5c5e4
Compare
d131026
to
35aae90
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave it to others to stamp on code, but stylistically this is a great improvement. Thank you Sean!
35aae90
to
19afff1
Compare
6cfb676
to
c97860e
Compare
7d507e5
to
b446704
Compare
c97860e
to
0cd2011
Compare
b446704
to
8df9d08
Compare
0cd2011
to
9d35d69
Compare
8df9d08
to
c29dd24
Compare
9d35d69
to
ef69f9a
Compare
c29dd24
to
af5089f
Compare
ef69f9a
to
92de7ff
Compare
af5089f
to
e4b55ba
Compare
92de7ff
to
9c0a2cf
Compare
e4b55ba
to
8857f68
Compare
9c0a2cf
to
46fc155
Compare
e1144f9
to
a46f596
Compare
a46f596
to
bd3c839
Compare
im on team however, i did a quick research in popular python libs:
where some list those as "parameters" and some are "attributes". wonder if we could leave things as "parameters" and not differentiate them? im fine either way. if we want to be right, it's worth checking with other folks who have more core python understanding. |
What's the status here? Requesting changes to get this out of my queue. FWIW, I'm in favor of the args approach. Formatting is clearly a step function improvement over attrs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
back to q
Graphite Automations"Label and add CE on all Docs" took an action on this PR • (09/28/24)3 reviewers were added and 1 label was added to this PR based on Pedram Navid's automation. |
Summary & Motivation
Currently in the codebase, some classes use
Attributes:
and others useArgs:
to list class parameters in docstrings. While the semantics between these are technically different (in principle class attributes need not correspond to constructor params at all), in practice I believe that everywhere we use "Attributes" we are really documenting constructor params. In any case we have no need to directly document attributes since we expose them through@property
."Attributes" and "Args" cases render quite differently (see screenshots). This PR:
Attributes
toArgs
(which renders more compactly and consistently with functions)Attributes:
is detected."Args" style (preferred, enforced by this PR):
"Attributes" style:
How I Tested These Changes
Built docs.