From c8f60c958888de0794f6400b11df7f34bcb1ec15 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 10 Feb 2023 18:06:48 -0500 Subject: [PATCH] Improve implicit-namespace-package documentation --- crates/ruff/src/rules/flake8_no_pep420/rules.rs | 15 +++++++++------ docs/rules/implicit-namespace-package.md | 15 +++++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/crates/ruff/src/rules/flake8_no_pep420/rules.rs b/crates/ruff/src/rules/flake8_no_pep420/rules.rs index 28394b4e20..879a431f6d 100644 --- a/crates/ruff/src/rules/flake8_no_pep420/rules.rs +++ b/crates/ruff/src/rules/flake8_no_pep420/rules.rs @@ -18,13 +18,16 @@ define_violation!( /// imported. /// /// Directories that lack an `__init__.py` file can still be imported, but - /// they're indicative of a special kind of package, known as a namespace - /// package (see: [PEP 420](https://www.python.org/dev/peps/pep-0420/)). + /// they're indicative of a special kind of package, known as a "namespace + /// package" (see: [PEP 420](https://www.python.org/dev/peps/pep-0420/)). + /// Namespace packages are less widely used, so a package that lacks an + /// `__init__.py` file is typically meant to be a regular package, and + /// the absence of the `__init__.py` file is probably an oversight. /// - /// Namespace packages are a relatively new feature of Python, and they're - /// not widely used. So a package that lacks an `__init__.py` file is - /// typically meant to be a regular package, and the absence of the - /// `__init__.py` file is probably an oversight. + /// Note that namespace packages can be specified via the + /// [`namespace-packages`](https://github.com/charliermarsh/ruff#namespace-packages) + /// configuration option. Adding a namespace package to the configuration + /// will suppress this violation for a given package. pub struct ImplicitNamespacePackage(pub String); ); impl Violation for ImplicitNamespacePackage { diff --git a/docs/rules/implicit-namespace-package.md b/docs/rules/implicit-namespace-package.md index 8125dfb5f3..1ef4a4f68e 100644 --- a/docs/rules/implicit-namespace-package.md +++ b/docs/rules/implicit-namespace-package.md @@ -12,10 +12,13 @@ package, and so it can be imported the same way a module can be imported. Directories that lack an `__init__.py` file can still be imported, but -they're indicative of a special kind of package, known as a namespace -package (see: [PEP 420](https://www.python.org/dev/peps/pep-0420/)). +they're indicative of a special kind of package, known as a "namespace +package" (see: [PEP 420](https://www.python.org/dev/peps/pep-0420/)). +Namespace packages are less widely used, so a package that lacks an +`__init__.py` file is typically meant to be a regular package, and +the absence of the `__init__.py` file is probably an oversight. -Namespace packages are a relatively new feature of Python, and they're -not widely used. So a package that lacks an `__init__.py` file is -typically meant to be a regular package, and the absence of the -`__init__.py` file is probably an oversight. \ No newline at end of file +Note that namespace packages can be specified via the +[`namespace-packages`](https://github.com/charliermarsh/ruff#namespace-packages) +configuration option. Adding a namespace package to the configuration +will suppress this violation for a given package. \ No newline at end of file