python / python/typeshed

Should __module__ be defined as class attribute?

Open
#12,128 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

Ref. https://github.com/python/typeshed/blob/58f2a795bac5924367d21961af53a32af7bb5727/stdlib/builtins.pyi#L98

This results in mypyc raising an error upon code accessing obj.__class__.__module__, which I believe is the canonical way to get the attribute. See https://github.com/mypyc/mypyc/issues/1055

Note that Cython doesn't define obj.__module__, therefore it makes difficult to write portable code.

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.

Research direction

Inspect stdlib/builtins.pyi around line 98 and review the linked mypyc issue to understand how module is currently modeled. Confirm the expected behavior for obj.class.module and account for the portability concern raised about Cython; done means the stub accurately supports the canonical access pattern.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.