MongoEngine / MongoEngine/mongoengine

Pylint and mongoengine's data model

Open
#1,290 3 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

Hi there,

With latest pylint update the lint fail on the documents and the fields (whereas it doesn't fail for Django ORM for instance). Here is a way to reproduce:

# in module.py
import mongoengine

class Doc(mongoengine.Document):

    string_field = mongoengine.StringField()
    dict_field = mongoengine.DictField()
    list_field = mongoengine.ListField()

    def do_stuff(self):
        for element in self.list_field:
            print element
        return self.string_field[0:7] in self.dict_field
# in shell
$ pip install mongoengine==0.10.6 pylint=1.5.5
$ pylint module.py -r no
E: 10,18: Non-iterable value self.list_field is used in an iterating context (not-an-iterable)
E:  9,41: Value 'self.dict_field' doesn't support membership test (unsupported-membership-test)
E:  9,15: Value 'self.string_field' is unsubscriptable (unsubscriptable-object)

Any idea how to fix this?

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 reproducing the reported diagnostics with the module.py example and the pinned mongoengine and pylint versions from the issue. Trace how MongoEngine document fields are exposed to Pylint, then verify the example no longer reports the three listed errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
databases, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.