python / python/mypy

get_dynamic_class_hook() doesn't work for inlined callls

Open
#7,556 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority-1-normal topic-plugins
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

This is currently supported using get_dynamic_class_hook():

Base = some.custom_class('Base', ...)

class Model(Base):
    ...

But it doesn't work if the call is inlined, which can often be annoying:

class Model(some.custom_class('Base', ...)):  # the hook is not called here
    ...

We can support the second use case by calling the same hook with the l.h.s. name set to None.

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

Start by tracing the existing get_dynamic_class_hook() handling and how the left-hand-side name is passed for the separate assignment form. Add coverage for an inline custom_class() call in a class base, and consider the work done when the hook is called for that form with the left-hand-side name set to None.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.