Skip to content

Commit

Permalink
Avoid D100 for Jupyter Notebooks (#8816)
Browse files Browse the repository at this point in the history
This PR avoids triggering `D100` for Jupyter Notebooks.

Part of #8669
  • Loading branch information
dhruvmanila authored Nov 22, 2023
1 parent 63a87dd commit 0cb438d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
43 changes: 43 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pydocstyle/D100.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "33faf7ad-a3fd-4ac4-a0c3-52e507ed49df",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello world!\n"
]
}
],
"source": [
"print(\"Hello world!\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (ruff-playground)",
"language": "python",
"name": "ruff-playground"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
1 change: 1 addition & 0 deletions crates/ruff_linter/src/rules/pydocstyle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ mod tests {
#[test_case(Rule::UndocumentedPublicMethod, Path::new("D.py"))]
#[test_case(Rule::UndocumentedPublicMethod, Path::new("setter.py"))]
#[test_case(Rule::UndocumentedPublicModule, Path::new("D.py"))]
#[test_case(Rule::UndocumentedPublicModule, Path::new("D100.ipynb"))]
#[test_case(
Rule::UndocumentedPublicModule,
Path::new("_unrelated/pkg/D100_pub.py")
Expand Down
3 changes: 3 additions & 0 deletions crates/ruff_linter/src/rules/pydocstyle/rules/not_missing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ pub(crate) fn not_missing(
kind: ModuleKind::Module,
..
}) => {
if checker.source_type.is_ipynb() {
return true;
}
if checker.enabled(Rule::UndocumentedPublicModule) {
checker.diagnostics.push(Diagnostic::new(
UndocumentedPublicModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
source: crates/ruff_linter/src/rules/pydocstyle/mod.rs
---

0 comments on commit 0cb438d

Please sign in to comment.