-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add class attributes checking support #122
Comments
Hi @Oreilles , thanks for submitting this issue. From my perspective, the potential difficulty with this suggestion is: instance attributes are difficult to check. Here's an example of "class attributes" and "instance attributes", in case there are any confusions: class Car:
# Class attribute
num_wheels = 4
def __init__(self, make, model):
# Instance attributes
self.make = make
self.model = model According to the Google style guide, if we are to document public attributes, we should document both class attributes and instance attributes. The order and type hints of instance attributes are not easy to check (we may not want to enforce order anyways). |
Came here after realizing that my dataclass attributes were not being checked. Maybe an option that can be set to enforce checking class attributes with caveats shown on screen? |
Hi @Gabriel-p and @Oreilles , I've implemented this functionality via a large code change. The changes are published as a new version (0.5.0). |
Hi @jsh9 I'm testing this new version now and I get this error:
where the error occurs is this one |
Hi @Gabriel-p , thanks for testing it. It's a bug that I wrote. I fixed it in #132 and it's published as 0.5.1. Btw, I read your code example in https://github.com/asteca/ASteCA/blob/334e56ec57a6bd726b2bf12a3b87d9eed6131971/asteca/cluster.py, and I think you'd need to update your docstring to use |
Thank you @jsh9. I updated and that issue is gone but there seems to be a few new issue now. Running
on my package used to find lots of issues with files in the (ALso, minor correction in https://jsh9.github.io/pydoclint/checking_class_attributes.html: |
I love this addition, but I feel like the implementation within dataclasses could be more flexible. |
Hi @Gabriel-p , I was able to reproduce it on my end. I created #139 to track this. |
Hi @jonyscathe : thank you for your comment! I had thought about the same thing that you did, and I shared my thought in an earlier comment above (#122 (comment)). If we are to treat them both class attributes and "instance attributes" as "parameters", here is what would happen:
That's why I think distinguishing class attributes and "parameters" is an acceptable compromise. I would admit that it's not perfect, but it seems the "lesser of two evals" given Python's design. |
It would be great if it was possible, in addition to checking function docstrings, to also check for missordered, missing, unexpected, or inconsistent class attributes in docstrings. Here's a simple class example to show how class attributes can be documented in Google style:
The text was updated successfully, but these errors were encountered: