-
Notifications
You must be signed in to change notification settings - Fork 27
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
Overhaul docs, add pydoclint
and custom formatter
#1314
Conversation
1ef438b
to
b03fb56
Compare
b03fb56
to
b499193
Compare
9eec8c6
to
27f4564
Compare
Started out with 868 issues on master:
...now down to 139:
...and finally, 0 🥳 |
e461a08
to
ddd2c48
Compare
0b98bcc
to
bb827f2
Compare
Codecov Report
@@ Coverage Diff @@
## master #1314 +/- ##
==========================================
- Coverage 90.42% 90.34% -0.09%
==========================================
Files 110 110
Lines 13515 13514 -1
==========================================
- Hits 12221 12209 -12
- Misses 1294 1305 +11
|
5323343
to
296e291
Compare
Should I bump version? Perhaps "massive" doc fixes is okay? 🤷 |
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.
Only a few minor comments.
@@ -739,11 +744,18 @@ def store_partial_result(self, res: DataPointListItem) -> Optional[List[Splittin | |||
return self._split_self_into_new_subtasks_if_needed(last_ts) | |||
return None | |||
|
|||
def _create_subtasks_idxs(self, n_new_tasks: int) -> Iterable[Tuple[float, ...]]: | |||
def _create_subtasks_idxs(self, n_new_tasks: int) -> Generator[Tuple[float, ...], None, None]: |
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 think the type hint for generators is not very good, thus I think the old one should stay, if it is possible configure the linter to do so.
Note I am not alone https://stackoverflow.com/questions/42531143/how-to-type-hint-a-generator-in-python-3
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 used to agree with this, but was convinced otherwise by the maintainer of pydoclint
: jsh9/pydoclint#68 (comment)
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.
MASSIVE work 💪Docs just leveled up 💯
pyproject.toml
Outdated
@@ -14,6 +14,18 @@ packages = [{ include="cognite", from="." }] | |||
[tool.ruff.pyupgrade] | |||
keep-runtime-typing = true | |||
|
|||
[tool.pydoclint] |
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.
Can we configure it using cmd line args in the pre-commit file instead? We prefer putting it there, only in here if that doesn't work.
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.
Absolutely 👌
49f6ae1
to
8bd3e82
Compare
pydoclint
pydoclint
and custom formatter
a537899
to
6ee53fc
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.
Some nitpicking
cognite/client/_api_client.py
Outdated
@@ -68,24 +64,25 @@ | |||
|
|||
class APIClient: | |||
_RESOURCE_PATH: str | |||
_RETRYABLE_POST_ENDPOINT_REGEX_PATTERNS = frozenset( |
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.
This type of change is not well suited in a 6K line PR of formatting. cognite-sdk-experimental depends on adding regexes to this set, so we're potentially breaking them here depending on how exactly it's done.
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.
Yes, I agree it should probably be put in a separate PR; was a new version of ruff
that started complaining about this not being a classvar (as set is ofc mutable).
I see that a "similar" issue has happened before 😉 https://github.com/cognitedata/cognite-sdk-python-experimental/pull/351/files
Conclusion: This change does not affect the experimental SDK, as it is doing s1 |= s2
, which is just s1 = s1 + s2
, i.e. not an in-place operation. The experimental SDK thus adopts this correction to frozenset
without side effects (I've checked all releases back to the "happening" linked above).
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 reverted the change and will move it to a separate PR 👍
@@ -185,7 +178,7 @@ def iterate_data( | |||
external_id: str, | |||
start: str | None = None, | |||
limit: int = DATAPOINT_SUBSCRIPTION_DATA_LIST_LIMIT_DEFAULT, | |||
) -> Iterator[DatapointSubscriptionBatch]: | |||
) -> Generator[DatapointSubscriptionBatch, None, None]: |
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.
Can stay an Iterator
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 agree, but then we either need to drop pydoclint
(you can't convince the maintainer on this one, unfortunately: https://jsh9.github.io/pydoclint/notes_generator_vs_iterator.html) or ignore all checks on return types. I think just using Generator
is the easy solution here.
This reverts commit 600466e.
Co-authored-by: Anders Albert <[email protected]>
13eb797
to
6e07684
Compare
Description
Step 1: Add docstring linter
Step 2: Fix 1 million errors
Note
It seems the linter struggles with
|
(Union) in return annotations. I have raised an issue and is waiting for a response. jsh9/pydoclint#66--> The maintainer fixed it 😄
Also awaiting an answer for a different fix than excluding a file through pre-commit for the
with_
parameter forQuery
:jsh9/pydoclint#73
--> The maintainer fixed this one as well ❤️
Last bug in
pydoclint
, currently awaiting response: jsh9/pydoclint#75--> ...and fixed 🚀
Checklist:
If a new method has been added it should be referenced in cognite.rst in order to generate docs based on its docstring.