Skip to content
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

[darglint] Implement docstring-missing-exception and docstring-extraneous-exception (DAR401, DAR402) #11471

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

augustelalande
Copy link
Contributor

@augustelalande augustelalande commented May 19, 2024

Summary

These are the first rules implemented as part of #458, but I plan to implement more.

Specifically, this implements docstring-missing-exception which checks for raised exceptions not documented in the docstring, and docstring-extraneous-exception which checks for exceptions in the docstring not present in the body.

Test Plan

Test fixtures added for both google and numpy style.

Copy link

codspeed-hq bot commented May 19, 2024

CodSpeed Performance Report

Merging #11471 will not alter performance

Comparing augustelalande:darglint (3413e59) with main (46fcd19)

Summary

✅ 30 untouched benchmarks

Copy link
Contributor

github-actions bot commented May 19, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+2239 -0 violations, +0 -0 fixes in 3 projects; 47 projects unchanged)

apache/airflow (+1844 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ airflow/api/__init__.py:47:15: DAR401 Raised exception `AirflowException` missing from docstring
+ airflow/api/client/json_client.py:55:19: DAR401 Raised exception `OSError` missing from docstring
+ airflow/api/common/delete_dag.py:62:15: DAR401 Raised exception `AirflowException` missing from docstring
+ airflow/api/common/delete_dag.py:65:15: DAR401 Raised exception `DagNotFound` missing from docstring
+ airflow/api/common/experimental/__init__.py:37:15: DAR401 Raised exception `DagNotFound` missing from docstring
+ airflow/api/common/experimental/__init__.py:43:15: DAR401 Raised exception `DagNotFound` missing from docstring
+ airflow/api/common/experimental/__init__.py:46:15: DAR401 Raised exception `TaskNotFound` missing from docstring
+ airflow/api/common/experimental/__init__.py:55:15: DAR401 Raised exception `DagRunNotFound` missing from docstring
+ airflow/api/common/experimental/get_code.py:44:15: DAR401 Raised exception `AirflowException` missing from docstring
+ airflow/api/common/experimental/get_task_instance.py:44:15: DAR401 Raised exception `TaskInstanceNotFound` missing from docstring
+ airflow/api/common/experimental/get_task_instance.py:48:11: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/experimental/pool.py:40:15: DAR401 Raised exception `AirflowBadRequest` missing from docstring
+ airflow/api/common/experimental/pool.py:44:15: DAR401 Raised exception `PoolNotFound` missing from docstring
+ airflow/api/common/experimental/pool.py:61:15: DAR401 Raised exception `AirflowBadRequest` missing from docstring
+ airflow/api/common/experimental/pool.py:66:15: DAR401 Raised exception `AirflowBadRequest` missing from docstring
+ airflow/api/common/experimental/pool.py:71:15: DAR401 Raised exception `AirflowBadRequest` missing from docstring
+ airflow/api/common/experimental/pool.py:92:15: DAR401 Raised exception `AirflowBadRequest` missing from docstring
+ airflow/api/common/experimental/pool.py:95:15: DAR401 Raised exception `AirflowBadRequest` missing from docstring
+ airflow/api/common/experimental/pool.py:99:15: DAR401 Raised exception `PoolNotFound` missing from docstring
+ airflow/api/common/mark_tasks.py:123:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:126:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:130:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:133:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:138:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:300:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:333:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:400:19: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:403:19: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:406:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:453:19: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:456:19: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:460:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:544:19: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:547:19: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/mark_tasks.py:550:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/trigger_dag.py:123:15: DAR401 Raised exception `DagNotFound` missing from docstring
+ airflow/api/common/trigger_dag.py:56:15: DAR401 Raised exception `DagNotFound` missing from docstring
+ airflow/api/common/trigger_dag.py:61:15: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/trigger_dag.py:69:19: DAR401 Raised exception `ValueError` missing from docstring
+ airflow/api/common/trigger_dag.py:82:15: DAR401 Raised exception `DagRunAlreadyExists` missing from docstring
+ airflow/api_connexion/endpoints/config_endpoint.py:87:19: DAR401 Raised exception `NotFound` missing from docstring
... 1803 additional changes omitted for project

bokeh/bokeh (+189 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ src/bokeh/application/application.py:168:19: DAR401 Raised exception `RuntimeError` missing from docstring
+ src/bokeh/application/handlers/code_runner.py:94:19: DAR401 Raised exception `ValueError` missing from docstring
+ src/bokeh/application/handlers/directory.py:142:19: DAR401 Raised exception `ValueError` missing from docstring
+ src/bokeh/application/handlers/directory.py:153:19: DAR401 Raised exception `ValueError` missing from docstring
+ src/bokeh/client/connection.py:213:19: DAR401 Raised exception `RuntimeError` missing from docstring
+ src/bokeh/client/connection.py:215:19: DAR401 Raised exception `RuntimeError` missing from docstring
... 182 additional changes omitted for rule DAR401
+ src/bokeh/resources.py:165:1: DAR402 KeyError not explicitly raised.
+ src/bokeh/tile_providers.py:182:1: DAR402 ValueError not explicitly raised.
... 181 additional changes omitted for project

zulip/zulip (+206 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ analytics/lib/fixtures.py:57:15: DAR401 Raised exception `AssertionError` missing from docstring
+ analytics/lib/fixtures.py:59:15: DAR401 Raised exception `AssertionError` missing from docstring
+ confirmation/models.py:102:15: DAR401 Raised exception `ConfirmationKeyError` missing from docstring
+ confirmation/models.py:105:15: DAR401 Raised exception `ConfirmationKeyError` missing from docstring
+ confirmation/models.py:115:15: DAR401 Raised exception `ConfirmationKeyError` missing from docstring
+ confirmation/models.py:96:15: DAR401 Raised exception `ConfirmationKeyError` missing from docstring
+ corporate/lib/stripe.py:1160:19: DAR401 Raised exception `BillingError` missing from docstring
+ corporate/lib/stripe.py:1209:23: DAR401 Raised exception `StripeCardError` missing from docstring
+ corporate/views/remote_billing_page.py:203:15: DAR401 Raised exception `AssertionError` missing from docstring
+ corporate/views/remote_billing_page.py:218:15: DAR401 Raised exception `JsonableError` missing from docstring
... 196 additional changes omitted for project

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
DAR401 2237 2237 0 0 0
DAR402 2 2 0 0 0

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@charliermarsh charliermarsh added rule Implementing or modifying a lint rule docstring Related to docstring linting or formatting labels May 20, 2024
@cr1901
Copy link

cr1901 commented May 22, 2024

If this PR is accepted, will this preclude pydoclint (darglint successor but not really backwards-compat) support in the future? While pydoclint is the tool I personally use, it seems since yesterday, there are few thumbs-up asking about using pydoclint as a base instead.

@augustelalande
Copy link
Contributor Author

I'm not opposed to using pydocstyle instead, but I'll wait until I get a review from the ruff team to change anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docstring Related to docstring linting or formatting rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants