Pylint explicit return
pylint-explicit-return adds the Pylint diagnostic
missing-explicit-return (C8716). It reports functions that can reach
the end of their body implicitly. A bare return, a return expression, or an
escaping raise satisfies the rule on that path.
Use the plugin
Install the package into the environment that runs Pylint. The plugin requires Python 3.11 or newer and Pylint 4.1.4 or newer in the 4.x series.
python -m pip install pylint-explicit-return
Add the plugin and disable useless-return in your project's pyproject.toml.
If those lists already exist, append these entries.
[tool.pylint.main]
load-plugins = ["pylint_explicit_return"]
[tool.pylint.messages_control]
disable = ["useless-return"]
For example, the following function reports a diagnostic because
print(value) can finish and execution then reaches the end of the body.
def save(value: str) -> None:
if not value:
raise ValueError("A value is required")
print(value)
Add a bare return after print(value) to satisfy the rule. To suppress the
diagnostic for a single function, put
# pylint: disable-next=missing-explicit-return immediately above its
definition. Pylint's inconsistent-return-statements rule can remain enabled.
Use return None where a function's other branches return a value and you want
to satisfy both rules.
How the checker handles paths
The checker analyzes every function body independently, including methods,
tests, nested functions, coroutines, and generators. A final yield or
await can resume and fall through. Use a bare return to end an async
generator explicitly. Return annotations such as NoReturn have no effect
on the diagnostic. For example, the bare return supplies an explicit exit
when this async generator resumes after yielding its last item.
async def numbers():
yield 1
return
The checker skips .pyi files, typing overload signatures, and abstract or
protocol methods whose bodies contain only a docstring, pass, or an
ellipsis. It checks executable implementations and ordinary placeholder
functions.
The analysis is conservative about dynamic Python behavior. It treats
unknown iterables as potentially empty, considers exceptions from expressions
and possible handler matches, and assumes a context manager may suppress an
exception. It can therefore report fallthrough when a handler is unreachable
or a context manager never suppresses exceptions. Calls are assumed able to
return, and match exhaustiveness depends on an unguarded irrefutable
pattern or a subsequent exit.
For example, the checker can flag the following function. It considers a
path where the manager suppresses an exception raised while evaluating the
return expression. Python's nullcontext() propagates the exception.
from contextlib import nullcontext
def item_count(items: list[str]) -> int:
with nullcontext():
return len(items)
Develop
Use Python 3.11 or newer and uv. Run the checks with tox and tox-uv.
uvx --with tox-uv tox -e lint,py313
Run uvx --with tox-uv tox to use the full interpreter matrix, or run uvx --with tox-uv tox -e format
to format the code.
With CPython 3.15 and dill 0.4.1, Pylint can fail to start parallel workers
because dill accesses the removed co_lnotab attribute. The failure also
occurs with stock Pylint. Use -j 1 with that combination.
Release
The release workflow uses nopt and runs when a version tag is pushed. Set the
version in pyproject.toml and update the changelog before
tagging the matching commit. Configure the GitHub pypi environment and register
the repository, release.yml workflow, and environment as a PyPI Trusted
Publisher before the first release.
See the nopt release instructions for tag, version, and changelog requirements.
Metadata
Release files for pylint-explicit-return 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pylint_explicit_return-0.1.0.tar.gz | 14.3 kB | With provenance | Details for pylint_explicit_return-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pylint_explicit_return-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pylint_explicit_return-0.1.0-py3-none-any.whl |
Total release size: 23.2 kB
Release files / pylint_explicit_return-0.1.0.tar.gz
| Download URL | pylint_explicit_return-0.1.0.tar.gz |
|---|---|
| Size | 14.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cacbc0bfd0b3bf18fdcf7c3eb437fe4825c7d2014414e3442bbd29c19b6b29e5
|
|
BLAKE2b-256 checksum How to use checksums |
f5f4acc37264600360b844c78807537b0995a8a6c1cc2f5a6a3ec7aa9a1a2ff5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / pylint_explicit_return-0.1.0-py3-none-any.whl
| Download URL | pylint_explicit_return-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec2079fbec5047f5d5934a8f644af91c6dd419d899146a81182759fb01b711c1
|
|
BLAKE2b-256 checksum How to use checksums |
7541a5e705bd0c27b794581c92391273dd4432bd890d91b7b1dff05ebdb62a34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for pylint-explicit-return 0.1.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pylint_explicit_return-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA 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.