pylint-dev / pylint-dev/astroid

Understand __missing__

Open
#145 0 comments 0 reactions 0 assignees View on GitHub
Enhancement ✨
Dominant language
Python
Stars
582
Forks
357
Avg merge
1d 1h
Merged PRs (30d)
23

Description

Originally reported by: **Claudiu Popa (BitBucket: [PCManticore](http://bitbucket.org/PCManticore), GitHub: @PCManticore)**

---

We could understand **missing**: when a key is not found in a dictionary, if it provides the dunder missing special method, then that method will be called and whatever is returned, will be the result of key access:

```
#!python

class A(dict):
def __missing__(self, key): return 42

a = A()
print(a[10])
```

---
- Bitbucket: https://bitbucket.org/logilab/astroid/issue/145

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how astroid handles dictionary key access and the __missing__ special method for dict subclasses, using the example in the issue as the expected behavior. Done means key access invokes __missing__ when the key is absent and uses its returned value.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.