René's URL Explorer Experiment


Title: Option to report `deprecated` only for symbols defined in selected packages (inverse of `deprecated_calls_exclude`) · Issue #22026 · python/mypy · GitHub

Open Graph Title: Option to report `deprecated` only for symbols defined in selected packages (inverse of `deprecated_calls_exclude`) · Issue #22026 · python/mypy

X Title: Option to report `deprecated` only for symbols defined in selected packages (inverse of `deprecated_calls_exclude`) · Issue #22026 · python/mypy

Description: Feature Add a way to report [deprecated] only for deprecated symbols defined in selected packages, the inverse of deprecated_calls_exclude: [tool.mypy] enable_error_code = ["deprecated"] deprecated_calls_include = ["mylib"] With this, us...

Open Graph Description: Feature Add a way to report [deprecated] only for deprecated symbols defined in selected packages, the inverse of deprecated_calls_exclude: [tool.mypy] enable_error_code = ["deprecated"] deprecated...

X Description: Feature Add a way to report [deprecated] only for deprecated symbols defined in selected packages, the inverse of deprecated_calls_exclude: [tool.mypy] enable_error_code = ["deprecated"] ...

Opengraph URL: https://github.com/python/mypy/issues/22026

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Option to report `deprecated` only for symbols defined in selected packages (inverse of `deprecated_calls_exclude`)","articleBody":"**Feature**\n\nAdd a way to report `[deprecated]` only for deprecated symbols *defined* in selected packages, the inverse of `deprecated_calls_exclude`:\n\n```toml\n[tool.mypy]\nenable_error_code = [\"deprecated\"]\ndeprecated_calls_include = [\"mylib\"]\n```\n\nWith this, using `mylib.old_func` anywhere (in `mylib` itself, its tests, its examples) is an error, while deprecations defined in third-party packages or the stdlib are not reported. Matching would work exactly like `deprecated_calls_exclude` (prefix on the fully qualified name of the definition), and `deprecated_calls_exclude` would still apply on top of it, so `mylib` can be included while `mylib.compat` is excluded.\n\n**Pitch**\n\nThis is the use case of a library that deprecates its own API:\n\n1. Its own code must never use its own deprecated symbols. Otherwise it ships code that emits `DeprecationWarning`s that downstream users can do nothing about. This should fail CI.\n2. Deprecations in its dependencies must NOT fail CI. Libraries are tested against dependency ranges, so a new upstream release that adds a `@deprecated` breaks every unrelated PR on the next CI run. Often the fix is not even possible yet: when the replacement only exists in the release that deprecated the old name, switching to it means raising the lower bound of the dependency, which is a decision of its own.\n\nAt runtime we already get exactly this split with a pytest `filterwarnings = [\"error:.*mylib\\..* is deprecated:DeprecationWarning\"]` entry. Statically, none of the current options can express it:\n\n- `report_deprecated_as_note` is global: it makes our own deprecations non-fatal too.\n- Per-module overrides select the module being *checked*, not the module that *defines* the deprecated symbol, so they can't tell the two cases apart.\n- `deprecated_calls_exclude` can, but only by listing every dependency. That list has to include transitive packages reached through inheritance (a deprecated method inherited from a base class in another package is reported with that package's fully qualified name), test-only dependencies, and one entry per distribution when several share a namespace package (in our case a family of libraries sharing the `frequenz.*` namespace, so excluding `frequenz` would hide our own deprecations as well). The list has to be updated whenever dependencies change, and forgetting an entry brings back the exact CI break it is meant to prevent. An include list, on the other hand, is a single entry that never changes.\n\n`deprecated_calls_exclude` was added (#18641) for the opposite use case: a library excluding *its own* package because its tests exercise its deprecated API (#18435, and [this comment](https://github.com/python/mypy/pull/18192#issuecomment-2512775035) in #18192). Both cases seem common for libraries, and only this one has no reasonable configuration today.\n\nThe change should be small: it touches the two places that check `deprecated_calls_exclude`, [`TypeChecker.warn_deprecated`](https://github.com/python/mypy/blob/3b28c290153651fc14aef3c1a607d1119faebb35/mypy/checker.py#L8620-L8634) and [`TypeAnalyser.check_and_warn_deprecated`](https://github.com/python/mypy/blob/3b28c290153651fc14aef3c1a607d1119faebb35/mypy/typeanal.py#L842-L859), plus the option, docs and tests. I'd be happy to send a PR if this is acceptable.\n\nA possible generalization is a per-package severity. An include list makes dependency deprecations silent, but what would fit even better is keeping them visible but non-fatal, for example with `report_deprecated_as_note = true` plus a way to report `mylib` as an error anyway. That is close to what @JelleZijlstra suggested in https://github.com/python/mypy/issues/18435#issuecomment-2583224400 (a pattern mapped to a behavior, such as `ignore`, `note` or `error`); `deprecated_calls_include` would then be the special case \"everything else is ignored\". I know notes without errors were questioned in [#18192](https://github.com/python/mypy/pull/18192#issuecomment-2511907869), so I'm not attached to this part and it could be split into a separate issue; the include list alone already solves the CI problem.\n\nHaving something like this might also make it easier to enable `deprecated` by default, as announced in the 1.14 release notes, since projects could keep deprecations they don't control from failing their checks.\n","author":{"url":"https://github.com/llucax","@type":"Person","name":"llucax"},"datePublished":"2026-09-23T08:30:05Z","url":"https://github.com/python/mypy/issues/22026"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:779d87f4-d7b5-2e1a-16ab-93ee6f09e5a3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD69A:2148FB:20818F7:2C1DE09:6B001DB6
html-safe-nonce08c3f509b070402d3641b6fd2a28c4e4245e9f29efaf218542c52ab94ccaee14
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjlBOjIxNDhGQjoyMDgxOEY3OjJDMURFMDk6NkIwMDFEQjYiLCJ2aXNpdG9yX2lkIjoiNzE1MTE3ODg3OTU4NjAxNjY5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac832c7842213e4a3e80b4c4871d338401fa5faf486a6bb7dbd5cd7ce1d33eadb8
hovercard-subject-tagissue:5550840111
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/22026/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f3af4e6036325717996466ef7944103ebafc8c827b077578022f690275acf27f/python/mypy/issues/22026
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f3af4e6036325717996466ef7944103ebafc8c827b077578022f690275acf27f/python/mypy/issues/22026
og:image:altFeature Add a way to report [deprecated] only for deprecated symbols defined in selected packages, the inverse of deprecated_calls_exclude: [tool.mypy] enable_error_code = ["deprecated"] deprecated...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamellucax
hostnamegithub.com
expected-hostnamegithub.com
None4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0
turbo-cache-controlno-preview
go-importgithub.com/python/mypy git https://github.com/python/mypy.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id7053637
octolytics-dimension-repository_nwopython/mypy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7053637
octolytics-dimension-repository_network_root_nwopython/mypy
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release44c658b24abf00491fb7ae5f56d42c9f38cbeab2
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/22026#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F22026
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F22026
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fmypy
Reloadhttps://github.com/python/mypy/issues/22026
Reloadhttps://github.com/python/mypy/issues/22026
Reloadhttps://github.com/python/mypy/issues/22026
pythonhttps://github.com/python
mypyhttps://github.com/python/mypy
Codehttps://github.com/python/mypy
Issues2.7k (2.7k)https://github.com/python/mypy/issues
Pull requests546 (546)https://github.com/python/mypy/pulls
Actionshttps://github.com/python/mypy/actions
Projectshttps://github.com/python/mypy/projects
Wikihttps://github.com/python/mypy/wiki
Security and qualityhttps://github.com/python/mypy/security
Insightshttps://github.com/python/mypy/insights
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/22026
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/22026
Option to report deprecated only for symbols defined in selected packages (inverse of deprecated_calls_exclude)https://github.com/python/mypy/issues/22026#top
featurehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22feature%22
topic-pep-702PEP 702, @deprecatedhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-pep-702%22
https://github.com/llucax
llucaxhttps://github.com/llucax
on Sep 23, 2026https://github.com/python/mypy/issues/22026#issue-5550840111
#18641https://github.com/python/mypy/pull/18641
#18435https://github.com/python/mypy/issues/18435
this commenthttps://github.com/python/mypy/pull/18192#issuecomment-2512775035
#18192https://github.com/python/mypy/pull/18192
TypeChecker.warn_deprecatedhttps://github.com/python/mypy/blob/3b28c290153651fc14aef3c1a607d1119faebb35/mypy/checker.py#L8620-L8634
TypeAnalyser.check_and_warn_deprecatedhttps://github.com/python/mypy/blob/3b28c290153651fc14aef3c1a607d1119faebb35/mypy/typeanal.py#L842-L859
@JelleZijlstrahttps://github.com/JelleZijlstra
#18435 (comment)https://github.com/python/mypy/issues/18435#issuecomment-2583224400
#18192https://github.com/python/mypy/pull/18192#issuecomment-2511907869
ilevkivskyihttps://github.com/ilevkivskyi
featurehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22feature%22
topic-pep-702PEP 702, @deprecatedhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-pep-702%22
on Sep 23, 2026https://github.com/python/mypy/issues/22026#event-31703561035
https://github.com/kuldeeepy
kuldeeepyhttps://github.com/kuldeeepy
on Sep 24, 2026https://github.com/python/mypy/issues/22026#issuecomment-5818720073
#22038https://github.com/python/mypy/pull/22038
llucaxhttps://github.com/llucax
on Nov 18, 2026https://github.com/python/mypy/issues/22026#event-36522984209
fixup! Add a guideline on how to deprecate Python symbolshttps://github.com/llucax/frequenz-docs/commit/2280b89b5957b9e4ed140e10100e95809f5603f3
2280b89https://github.com/llucax/frequenz-docs/commit/2280b89b5957b9e4ed140e10100e95809f5603f3
fixup! Add a guideline on how to deprecate Python symbolshttps://github.com/llucax/frequenz-docs/commit/6ec4d3c1f4b15e4c2fb78d91686cc9a7d7663e85
6ec4d3chttps://github.com/llucax/frequenz-docs/commit/6ec4d3c1f4b15e4c2fb78d91686cc9a7d7663e85
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/22026
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/22026
featurehttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22feature%22
topic-pep-702PEP 702, @deprecatedhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-pep-702%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.