Avoid D100 for Jupyter Notebooks (#8816)

This PR avoids triggering `D100` for Jupyter Notebooks.

Part of #8669
This commit is contained in:
Dhruv Manilawala 2023-11-22 09:26:25 -06:00 committed by GitHub
parent 63a87dda63
commit 0cb438dd65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 0 deletions

View file

@ -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
}

View file

@ -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")

View file

@ -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,

View file

@ -0,0 +1,4 @@
---
source: crates/ruff_linter/src/rules/pydocstyle/mod.rs
---