Skip to content

Commit

Permalink
fix bug with AttributeError (issue #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timofey Trukhanov committed Aug 20, 2015
1 parent e979438 commit b97e974
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion django_linter/checkers/views.py
Expand Up @@ -67,7 +67,7 @@ def visit_getattr(self, node):
isinstance(parent, Getattr) and
parent.attrname == 'get'):
self.add_message('raw-get-post-access', node=node)
elif node.attrname == 'objects':
elif isinstance(parent, Getattr) and node.attrname == 'objects':
if parent.attrname == 'get':
if self._is_view_function or self._is_view_class:
if not self._is_inside_try_except:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -4,7 +4,7 @@

setup(
name='django_linter',
version='0.6.dev1',
version='0.6.dev2',
packages=find_packages(exclude=['tests*']),
description='Linter for django projects',
long_description=open('README.rst').read(),
Expand Down
2 changes: 2 additions & 0 deletions tests/input/func_views_objects_get_without_doesnotexist.py
Expand Up @@ -46,4 +46,6 @@ class IndexView(TemplateView):
def get_context_data(self, **kwargs):
ctx = super(IndexView, self).get_context_data(**kwargs)
ctx['cat'] = Category.objects.get(pk=kwargs['cat_id'])
# check this not raises exception
self._manager = Category.objects # pylint: disable=W0201
return ctx

0 comments on commit b97e974

Please sign in to comment.