René's URL Explorer Experiment


Title: Importing a regular package from a namespace package seems to break intermittently · Issue #10056 · python/mypy · GitHub

Open Graph Title: Importing a regular package from a namespace package seems to break intermittently · Issue #10056 · python/mypy

X Title: Importing a regular package from a namespace package seems to break intermittently · Issue #10056 · python/mypy

Description: Bug Report If you have a library that creates a namespace package (say ns_package) with a regular type-hinted package inside it (say reg_package), and you import the regular package as from ns_package import reg_package, mypy sometimes g...

Open Graph Description: Bug Report If you have a library that creates a namespace package (say ns_package) with a regular type-hinted package inside it (say reg_package), and you import the regular package as from ns_pack...

X Description: Bug Report If you have a library that creates a namespace package (say ns_package) with a regular type-hinted package inside it (say reg_package), and you import the regular package as from ns_pack...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Importing a regular package from a namespace package seems to break intermittently","articleBody":"**Bug Report**\r\nIf you have a library that creates a namespace package (say `ns_package`) with a regular type-hinted package inside it (say `reg_package`), and you import the regular package as `from ns_package import reg_package`, mypy sometimes gives the following error:\r\n\r\n```\r\nscript.py:1: error: Skipping analyzing 'ns_package': found module but no type hints or library stubs\r\nscript.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\nThe error only shows up intermittently. More details below.\r\n\r\n**To Reproduce**\r\n\r\n1. Create the following directory tree:\r\n```\r\n.\r\n├── lib/\r\n│   ├── ns_package/\r\n│   │   └── reg_package/\r\n│   │       ├── __init__.py\r\n│   │       └── py.typed\r\n│   └── setup.py\r\n└── script.py\r\n\r\n3 directories, 4 files\r\n```\r\nwith content\r\n```python\r\n# lib/ns_package/reg_package/__init__.py\r\nSOMETHING: int = 345\r\n\r\n# lib/setup.py\r\nfrom setuptools import setup, find_namespace_packages\r\n\r\nsetup(\r\n    name=\"ns_package.reg_package\",\r\n    description=\"\",\r\n    version=\"1.0\",\r\n    packages=find_namespace_packages(),\r\n    zip_safe=False,\r\n    package_data={\"\": [\"py.typed\"]},\r\n)\r\n\r\n# script.py\r\nfrom ns_package import reg_package\r\n\r\na = reg_package.SOMETHING\r\n\r\nprint(a)\r\n```\r\n2. Create venv, activate and install the lib and mypy: `python3.8 -m venv .venv; . .venv/bin/activate; python3.8 -m pip install -e ./lib/ mypy`\r\n3. Run mypy against `script.py` with `python3.8 -m mypy -p script`\r\n\r\n**Expected Behavior**\r\n\r\nMypy should report no errors since the library has a `py.typed` file and type annotations.\r\n\r\n**Actual Behavior**\r\n\r\nMypy's result changes with every run. Sometimes no error is reported. Sometimes the following error is reported:\r\n```\r\nscript.py:1: error: Skipping analyzing 'ns_package': found module but no type hints or library stubs\r\nscript.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\nFrom what I can tell, the error is **always** reported in every other run, consistently. Meaning if I run mypy twice in a row, one of them always fails and one of them always succeeds. This seems to suggest that mypy somehow maintains state from one run to the next?\r\n\r\nCouple of points to note:\r\n\r\n- If the import statement is changed to `import ns_package.reg_package as reg_package` or `from ns_package.reg_package import SOMETHING`, the error is gone.\r\n- Adding the `--namespace-packages` CLI flag doesn't change the result.\r\n- Whether the lib is installed as an editable package doesnt change the result.\r\n- Whether its installed from local dir or PyPi doesn't change the result.\r\n- If `ns_package` is just a directory in the cwd instead of an installed package, and the `--namespace-packages` CLI flag is passed, the error is gone.\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 0.800\r\n- Mypy command-line flags: `-p script`\r\n- Mypy configuration options from `mypy.ini` (and other config files): None\r\n- Python version used: 3.8.6\r\n- Operating system and version: Red Hat Enterprise Linux Server 7.9 (Maipo)\r\n","author":{"url":"https://github.com/Cnoor0171","@type":"Person","name":"Cnoor0171"},"datePublished":"2021-02-09T23:31:51Z","url":"https://github.com/python/mypy/issues/10056"}

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:ec09fe1f-eafb-10a5-95f8-eaacf27e315f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9518:36D598:2CDC:3CA6:6B00192E
html-safe-noncec286d5da0f8f91290def8b9c6c9ad532fac925944392cd7c1f7978c28457064e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTE4OjM2RDU5ODoyQ0RDOjNDQTY6NkIwMDE5MkUiLCJ2aXNpdG9yX2lkIjoiMTI4NzM4ODE4MzU5MTM5MzU4MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac90ddfda322c877d3964d295d79743dfd4d3cc1bfe09155c42c5bf85353e1db3d
hovercard-subject-tagissue:805013724
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/10056/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a032cc0187529c17dd38ef5768b4fdb24fdf9280996e1a9b9f206b598903e15c/python/mypy/issues/10056
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a032cc0187529c17dd38ef5768b4fdb24fdf9280996e1a9b9f206b598903e15c/python/mypy/issues/10056
og:image:altBug Report If you have a library that creates a namespace package (say ns_package) with a regular type-hinted package inside it (say reg_package), and you import the regular package as from ns_pack...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameCnoor0171
hostnamegithub.com
expected-hostnamegithub.com
Nonea2dd2291b1b13cc9c06f27ec92fa3dbaf34116fc24c9347b8539db61884c59f4
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
release70121d4e855ee0bb7b75cf15d061d91f8863c0f8
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/10056#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F10056
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%2F10056
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/10056
Reloadhttps://github.com/python/mypy/issues/10056
Reloadhttps://github.com/python/mypy/issues/10056
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/10056
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/10056
Importing a regular package from a namespace package seems to break intermittentlyhttps://github.com/python/mypy/issues/10056#top
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/Cnoor0171
Cnoor0171https://github.com/Cnoor0171
on Feb 9, 2021https://github.com/python/mypy/issues/10056#issue-805013724
Cnoor0171https://github.com/Cnoor0171
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%22
on Feb 9, 2021https://github.com/python/mypy/issues/10056#event-4312009193
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
on Feb 9, 2021https://github.com/python/mypy/issues/10056#issuecomment-776325381
#9852https://github.com/python/mypy/issues/9852
https://github.com/Cnoor0171
Cnoor0171https://github.com/Cnoor0171
on Feb 10, 2021https://github.com/python/mypy/issues/10056#issuecomment-776330233
@hauntsaninjahttps://github.com/hauntsaninja
Cnoor0171https://github.com/Cnoor0171
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Feb 24, 2021https://github.com/python/mypy/issues/10056#event-4373764051
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
on Aug 4, 2021https://github.com/python/mypy/issues/10056#issuecomment-892412996
@Cnoor0171https://github.com/Cnoor0171
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
on Aug 6, 2021https://github.com/python/mypy/issues/10056#issuecomment-894489260
#10937https://github.com/python/mypy/pull/10937
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/10056
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/10056
bugmypy got something wronghttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22bug%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.