Mypy doesn't recognize `__loader__` global in Python 3.6

Open
#4,182 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
64/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
devtools

Research direction

Start by running the reported mypy command with --python-version 3.6 and inspect how built-in module globals such as name are represented in typeshed. The issue is done when loader.name is accepted without the undefined-name error, with the relevant behavior covered by a regression test.

Written by the indexing model from the issue text.

Description

bug false-positive priority-1-normal size-small topic-runtime-semantics
$ mypy --python-version 3.6 -c 'print(__loader__.name)'
<string>:1: error: Name '__loader__' is not defined

This might be a typeshed issue, but I can't figure out where globals like __name__ defined in typeshed. Feel free to redirect me!

Dominant language
Python
Stars
20.6k
Forks
3.3k
Avg merge
1d 18h
Merged PRs (30d)
54

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python/mypy

All issues in python/mypy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.