build(deps-dev): Bump pylint from 2.17.7 to 4.0.9 in /examples/bzlmod (#4383) Bumps [pylint](https://github.com/pylint-dev/pylint) from 2.17.7 to 4.0.9 in /examples/bzlmod and replaces `pylint-print` with `pylint-per-file-ignores`. `pylint-print 1.0.1` is incompatible with Pylint 4.0+ due to the removal of `IAstroidChecker` from `pylint.interfaces`. Replace it with `pylint-per-file-ignores` in `examples/bzlmod` to demonstrate plugin loading via `py_console_script_binary(deps = [...])`, and update `entry_points` tests and documentation accordingly. Fixes Dependabot alert 942: https://github.com/bazel-contrib/rules_python/security/dependabot/942 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/pylint-dev/pylint/releases">pylint's releases</a>.</em></p> <blockquote> <h2>v4.0.9</h2> <h2>What's new in Pylint 4.0.9?</h2> <p>Release date: 2026-09-23</p> <h2>Security Fixes</h2> <ul> <li>Someone without access to the configuration or linted code, but with access to the cache directory (predictable <code>PYLINT_HOME</code> on a multi-user host) can no longer write a crafted pickle that will runs arbitrary code when pylint access its stat cache. The result cache is now stored as JSON instead of pickle, preventing code-execution. The workaround is upgrading or not pointing <code>PYLINT_HOME</code> to an untrusted, shared, or group-writable directory. The default value, <code>~/.cache/pylint</code>, is writable only by the user running pylint. (CVE with the same information pending)</li> </ul> <h2>False Positives Fixed</h2> <ul> <li> <p>Fixed a false positive for <code>no-self-use</code> on a method that only uses <code>self</code> before a locally defined class (or other nested method), because the checker's could-be-a-function tracking state was not restored after visiting the nested method.</p> <p>Closes <a href="https://redirect.github.com/pylint-dev/pylint/issues/3705">#3705</a></p> </li> <li> <p>Fix a false positive for :ref:<code>not-callable</code> when calling functions constructed with <code>types.FunctionType</code> or <code>types.LambdaType</code>.</p> <p>Closes <a href="https://redirect.github.com/pylint-dev/pylint/issues/7500">#7500</a></p> </li> <li> <p>Fix a false positive for <code>unnecessary-direct-lambda-call</code> when a directly called lambda in a class body wraps a comprehension containing an assignment expression. PEP 572 makes that a <code>SyntaxError</code> without the lambda's scope, so following the message produced code that would not compile.</p> <p>Closes <a href="https://redirect.github.com/pylint-dev/pylint/issues/9294">#9294</a></p> </li> <li> <p>Fix a false positive for :ref:<code>unnecessary-ellipsis</code> when an ellipsis is the sole body statement of a method defined on a <code>Protocol</code>.</p> <p>Closes <a href="https://redirect.github.com/pylint-dev/pylint/issues/9319">#9319</a></p> </li> <li> <p>Fix a false positive for :ref:<code>bad-exception-cause</code> when the bases of the class being raised from cannot be inferred, such as an exception deriving from a C extension class. :ref:<code>raising-non-exception</code> and :ref:<code>catching-non-exception</code> already guard the same <code>inherit_from_std_ex</code></p> </li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/pylint-dev/pylint/commit/303703fe107fa812c42a66edfc88a5702a63f1f1"><code>303703f</code></a> Bump pylint to 4.0.9, update changelog (<a href="https://redirect.github.com/pylint-dev/pylint/issues/11448">#11448</a>)</li> <li><a href="https://github.com/pylint-dev/pylint/commit/b342384e6cb10986f3fa66093d99464b3ced4199"><code>b342384</code></a> Fix block-scoped disable leaking into sibling elif/else blocks (<a href="https://redirect.github.com/pylint-dev/pylint/issues/11429">#11429</a>) (<a href="https://redirect.github.com/pylint-dev/pylint/issues/11445">#11445</a>)</li> <li><a href="https://github.com/pylint-dev/pylint/commit/58c87cffca9de2b3e89aa07b89686cbc90cfea2d"><code>58c87cf</code></a> Store the results cache as JSON instead of pickle</li> <li><a href="https://github.com/pylint-dev/pylint/commit/e3f4942a2ff51d28b69435587eee53ab44ebfb9c"><code>e3f4942</code></a> [Backport maintenance/4.0.x] Fix crash on failed attribute inference (<a href="https://redirect.github.com/pylint-dev/pylint/issues/11443">#11443</a>)</li> <li><a href="https://github.com/pylint-dev/pylint/commit/faf47f9f079c9461832a7bd7dcea61d44f6348b9"><code>faf47f9</code></a> [Backport maintenance/4.0.x] Fix false positive no-self-use when a method con...</li> <li><a href="https://github.com/pylint-dev/pylint/commit/20c7bb9ef1468b38e61de43d2e3a7314f938e04f"><code>20c7bb9</code></a> [Backport maintenance/4.0.x] Fix a crash in method-hidden for methods named a...</li> <li><a href="https://github.com/pylint-dev/pylint/commit/47e67578bef317ff0feb0211ba84ba3ba958645f"><code>47e6757</code></a> [Backport maintenance/4.0.x] Fix bad-exception-cause false positive when the ...</li> <li><a href="https://github.com/pylint-dev/pylint/commit/ae3ee5354062ca35c0d243f673a2bf3ee2e4f376"><code>ae3ee53</code></a> [Backport maintenance/4.0.x] Fix not-callable false positive for types.Functi...</li> <li><a href="https://github.com/pylint-dev/pylint/commit/3e444be6ef29e675f2f559960a60ee24a0372687"><code>3e444be</code></a> [Backport maintenance/4.0.x] Fix a crash in unnecessary-default-type-args for...</li> <li><a href="https://github.com/pylint-dev/pylint/commit/8f2dd4fcaa85fa43b33da6b0fed4af3a22314984"><code>8f2dd4f</code></a> [Backport maintenance/4.0.x] Fix declare-non-slot false positives for ClassVa...</li> <li>Additional commits viewable in <a href="https://github.com/pylint-dev/pylint/compare/v2.17.7...v4.0.9">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/bazel-contrib/rules_python/network/alerts). </details> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Richard Levasseur <richardlev@gmail.com>
This repository is the home of the core Python rules -- py_library, py_binary, py_test, and related symbols that provide the basis for Python support in Bazel. It also contains package installation rules for integrating with PyPI and other indices.
Documentation for rules_python is at https://rules-python.readthedocs.io and in the Bazel Build Encyclopedia.
Examples live in the examples directory.
The core rules are stable. Their implementation is subject to Bazel's backward compatibility policy. This repository aims to follow semantic versioning.
The Bazel community maintains this repository. Neither Google nor the Bazel team provides support for the code. However, this repository is part of the test suite used to vet new Bazel releases. See How to contribute page for information on our development workflow.
requirements.txt is how users have been defining dependencies for a long time. We support this to support legacy usecases or package managers that we don't support directly. Any additional information that we need will be retrieved from the SimpleAPI during the bzlmod extension evaluation phase. Then it will be written to the MODULE.bazel.lock file for future reuse. We have plans to support uv.lock file directly. uv is recommended for generating a fully locked requirements.txt file and we do provide a rule for it.py_binary, py_test rules should scale to large monorepos and we work hard to minimize the work done during analysis and build phase. What is more, the space requirements for should be minimal, so we strive to use symlinks rather than extracting wheels at build time. This means that for different configurations of the same build, we are not extracting the wheel multiple times thus scaling better over the time. From 2.0 onwards we are creating a virtual env for each target by creating an actual minimal virtual environment using symlinks. We plan on creating the traditional site-packages layout in the future by default.rules_python and this has resulted in a few PEPs supported within pure starlark - PEP440, PEP509.Common misconceptions:
rules_python has to keep backwards compatibility with google3. Whilst this might have been true in the past, rules_python is an open source project and any compatibility needs should come from the community - we have no requirement to keep this compatibility and are allowed to make our decisions. However, we do want to keep backwards compatibility as long as possible to not upset users with never ending migrations.rules_python is not caching pip downloads. With 2.0, we use Bazel's downloader by default and rely on bazel to provide the repository caching mechanisms. This means that for simpler setups this should result in transparent and scalable caching with the most recent bazel versions unless there are issues in the bazel itself.For detailed documentation, see https://rules-python.readthedocs.io
See Bzlmod support for more details.