pylint-dev / pylint-dev/astroid

Improve astroid's inference for simplejson & json

Open
#75 3 comments 0 reactions 0 assignees View on GitHub
Bug 🪳
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)**

---

The following stackoverflow post http://stackoverflow.com/questions/21545409/pylint-reports-maybe-no-member-error-for-data-loaded-via-simplejson describes a false positive
related to simplejson and json. It's more of an inference issue, so this should be fixed in astroid, rather than pylint.

```
#!python

import astroid.builder
builder = astroid.builder.AstroidBuilder()
ast = builder.string_build("""
import simplejson
import json
x = json.loads('"test"')
y = simplejson.loads('"test"')
""")

json_assignment, simplejson_assignment = list(ast.get_children())[2:]
print("json:", list(json_assignment.get_children())[-1].infered())
print("simplejson:", list(simplejson_assignment.get_children())[-1].infered())
```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Begin with astroid.builder.AstroidBuilder.string_build and inspect the inferred nodes produced for json.loads and simplejson.loads. Use the supplied reproduction to compare both results; done means inference no longer produces the reported false positive for the two equivalent calls. No test file is named in the issue, so locate the relevant inference tests before changing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
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.