Skip to content

Commit 3b2f545

Browse files
committed
Don't transform DoesNotExist. Fixes #81
1 parent f252f0a commit 3b2f545

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
* Update tests and require latest version of pylint (>=1.8), fixes
2828
[#53](https://github.com/landscapeio/pylint-django/issues/53),
2929
[#97](https://github.com/landscapeio/pylint-django/issues/97)
30+
* [#81](https://github.com/landscapeio/pylint-django/issues/81) Fix 'duplicate-except' false negative
31+
for except blocks which catch the `DoesNotExist` exception.
3032

3133
## Version 0.7.4
3234
* [#88](https://github.com/landscapeio/pylint-django/pull/88) Fixed builds with Django 1.10 (thanks to [federicobond](https://github.com/federicobond))

pylint_django/transforms/transforms/django_db_models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class Model(object):
88
pk = None
99

1010
MultipleObjectsReturned = MultipleObjectsReturned
11-
DoesNotExist = ObjectDoesNotExist
1211

1312
save = lambda *a, **kw: None
1413
delete = lambda *a, **kw: None
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Checks that Pylint does not complain about duplicate
3+
except blocks catching DoesNotExist exceptions:
4+
https://github.com/landscapeio/pylint-django/issues/81
5+
"""
6+
# pylint: disable=missing-docstring
7+
from django.db import models
8+
9+
10+
class Book(models.Model):
11+
name = models.CharField(max_length=100)
12+
13+
14+
class Author(models.Model):
15+
name = models.CharField(max_length=100)
16+
17+
def dummy_func():
18+
try:
19+
print("foo")
20+
except Book.DoesNotExist:
21+
print("bar")
22+
except Author.DoesNotExist:
23+
print("baz")

0 commit comments

Comments
 (0)