Skip to main content

pylint-google-style

Pylint plugins that enforce two import rules from the Google Python Style Guide:

  1. Import modules, not symbols — prefer from a.b import c and reference c.Symbol, rather than from a.b.c import Symbol.
  2. Use absolute imports, not relative imports — prefer from mypackage.utils import helper over from ..utils import helper.

Google publishes an official pylintrc alongside the style guide, but stock pylint has no checkers for these two import rules, so they go unenforced. This package fills that gap: use it together with Google's pylintrc, not instead of it.

Installation

uv add --dev pylint-google-style
# or
pip install pylint-google-style

Usage

Start from Google's official pylintrc as your baseline:

curl -O https://google.github.io/styleguide/pylintrc

Then enable these checkers by adding the plugins to that .pylintrc:

[MAIN]
load-plugins =
    pylint_google_style.import_module,
    pylint_google_style.relative_import

Or on the command line:

pylint --load-plugins=pylint_google_style.import_module,pylint_google_style.relative_import your_package/

Checks

Code Symbol Description
C9001 import-symbol-not-module A symbol was imported from a module; import the module instead.
C9003 import-symbol-not-package A symbol was imported from a top-level package; import the package.
C9002 relative-import A relative import was used; use an absolute import instead.
W9001 import-module-unresolvable The parent module could not be resolved, so the import was not checked.

__init__.py files are exempt from both checkers, since re-exporting symbols there is idiomatic.

Example

# flagged (C9001): symbol imported from a module
from os.path import join

# preferred
from os import path

path.join(...)
# flagged (C9002): relative import
from ..utils import helper

# preferred
from mypackage.utils import helper

Configuration

The import-module checker accepts additional modules to exempt from the symbol-vs-module rule (on top of the built-in exemptions for typing-related modules such as typing, typing_extensions, collections.abc, and __future__):

[IMPORT-MODULE]
import-module-exceptions =
    numpy,
    pandas

Development

uv sync
uv run pytest                       # run tests
uv run ruff check .                 # lint
uv run ruff format --check .        # formatting

License

MIT © Zhitao Gong

Metadata

Release files for pylint-google-style 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylint-google-style 0.1.2
File Size Uploaded Provenance Actions
pylint_google_style-0.1.2.tar.gz 8.8 kB Without provenance Details for pylint_google_style-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pylint-google-style 0.1.2
File Interpreter ABI Platform Actions
pylint_google_style-0.1.2-py3-none-any.whl Python 3 none any Details for pylint_google_style-0.1.2-py3-none-any.whl

Total release size: 21.4 kB

Release files / pylint_google_style-0.1.2.tar.gz

Download URL pylint_google_style-0.1.2.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
81c2b298c7bf4eb69b827810dc7b2c07a230401c469fb53adf7d41c2f5fbf1fa
BLAKE2b-256 checksum
How to use checksums
58a632b69896b203c223672c40cb1aac10e038eb7df53a04e12eb2bc4829d2a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pylint_google_style-0.1.2-py3-none-any.whl

Download URL pylint_google_style-0.1.2-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c4aa2ea9e69a31b79bbbd194011ec357fc2db318102df4fc71ce233cd8632b6
BLAKE2b-256 checksum
How to use checksums
3969bdc72416061b2a86cc2d3feecdc4c29682df9c0bad676b8bf96be3191d50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pylint-google-style 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page