File: func_noerror_duplicate_except_doesnotexist.py

package info (click to toggle)
pylint-django 2.0.13-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 660 kB
  • sloc: python: 1,807; sh: 13; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 524 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
Checks that Pylint does not complain about duplicate
except blocks catching DoesNotExist exceptions:
https://github.com/PyCQA/pylint-django/issues/81
"""
#  pylint: disable=missing-docstring
from django.db import models


class Book(models.Model):
    name = models.CharField(max_length=100)


class Author(models.Model):
    name = models.CharField(max_length=100)


def dummy_func():
    try:
        print("foo")
    except Book.DoesNotExist:
        print("bar")
    except Author.DoesNotExist:
        print("baz")