{"action":"created","issue":{"url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/858","repository_url":"https://api.github.com/repos/MongoEngine/mongoengine","labels_url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/858/labels{/name}","comments_url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/858/comments","events_url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/858/events","html_url":"https://github.com/MongoEngine/mongoengine/issues/858","id":55308677,"number":858,"title":"Class 'User' has no 'objects' member (no-member)","user":{"login":"warvariuc","id":1035452,"avatar_url":"https://avatars.githubusercontent.com/u/1035452?v=3","gravatar_id":"","url":"https://api.github.com/users/warvariuc","html_url":"https://github.com/warvariuc","followers_url":"https://api.github.com/users/warvariuc/followers","following_url":"https://api.github.com/users/warvariuc/following{/other_user}","gists_url":"https://api.github.com/users/warvariuc/gists{/gist_id}","starred_url":"https://api.github.com/users/warvariuc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/warvariuc/subscriptions","organizations_url":"https://api.github.com/users/warvariuc/orgs","repos_url":"https://api.github.com/users/warvariuc/repos","events_url":"https://api.github.com/users/warvariuc/events{/privacy}","received_events_url":"https://api.github.com/users/warvariuc/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MongoEngine/mongoengine/labels/Enhancement","name":"Enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2015-01-23T17:30:30Z","updated_at":"2016-07-25T02:55:36Z","closed_at":null,"body":"PyLint is complaining:\r\n> `Class 'User' has no 'objects' member (no-member)`\r\n> `Class 'User' has no 'DoesNotExist' member (no-member)`\r\n\r\nThis is because `objects` is assigned in the metaclass `base/metaclasses.py:345`:\r\n```\r\n        # Provide a default queryset unless exists or one has been set\r\n        if 'objects' not in dir(new_class):\r\n            new_class.objects = QuerySetManager()\r\n```\r\n\r\nI think having it defined in the base document would have the effect but be more discoverable:\r\n```\r\nclass Document(BaseDocument):\r\n    objects = QuerySetManager()\r\n```\r\n\r\nSimilarly you could do \r\n```\r\nfrom mongoengine.queryset import DoesNotExist, MultipleObjectsReturned\r\nclass Document(BaseDocument):\r\n    DoesNotExist = DoesNotExist\r\n    MultipleObjectsReturned = MultipleObjectsReturned\r\n```\r\n\r\nAlso the per-class exceptions can have their names to include model name:\r\n```\r\n        # Merge in exceptions with parent hierarchy\r\n        exceptions_to_merge = (DoesNotExist, MultipleObjectsReturned)\r\n        module = attrs.get('__module__')\r\n        for exc in exceptions_to_merge:\r\n            _name = exc.__name__\r\n            parents = tuple(getattr(base, _name) for base in flattened_bases\r\n                         if hasattr(base, _name)) or (exc,)\r\n            # Create new exception and set to new_class\r\n            exception = type(name + _name, parents, {'__module__': module})\r\n            setattr(new_class, _name, exception)\r\n```\r\nThus Sentry having such an exceptions + `__repr__` would give hint what model the exception belongs to."},"comment":{"url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/comments/234825703","html_url":"https://github.com/MongoEngine/mongoengine/issues/858#issuecomment-234825703","issue_url":"https://api.github.com/repos/MongoEngine/mongoengine/issues/858","id":234825703,"user":{"login":"boazin","id":5410799,"avatar_url":"https://avatars.githubusercontent.com/u/5410799?v=3","gravatar_id":"","url":"https://api.github.com/users/boazin","html_url":"https://github.com/boazin","followers_url":"https://api.github.com/users/boazin/followers","following_url":"https://api.github.com/users/boazin/following{/other_user}","gists_url":"https://api.github.com/users/boazin/gists{/gist_id}","starred_url":"https://api.github.com/users/boazin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boazin/subscriptions","organizations_url":"https://api.github.com/users/boazin/orgs","repos_url":"https://api.github.com/users/boazin/repos","events_url":"https://api.github.com/users/boazin/events{/privacy}","received_events_url":"https://api.github.com/users/boazin/received_events","type":"User","site_admin":false},"created_at":"2016-07-25T02:55:36Z","updated_at":"2016-07-25T02:55:36Z","body":"pylint is still failing on .objects call - any workaround?"}}
{"actor":{"display_login":"boazin"}}