Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate-except throws red-herring on DoesNotExist #81

Closed
gbataille opened this issue Aug 2, 2016 · 2 comments
Closed

duplicate-except throws red-herring on DoesNotExist #81

gbataille opened this issue Aug 2, 2016 · 2 comments

Comments

@gbataille
Copy link

Hi guys, I have the following issue.
I raised it originally to the pylint team who thinks this is actually due to some processing you are doing with the DoesNotExist (I guess for other code checks)!

pylint-dev/pylint#1050

Steps to reproduce

  1. in a django project with 2 models
  2. create a piece of code like this
    try:
        print("foo")
    except Model1.DoesNotExist:
        print("bar")
    except Model2.DoesNotExist:
        print("baz")

Current behavior

This raises a W0705 duplicate-except saying it's catching django.core.exceptions.ObjectDoesNotExist. both those exception (as far as I understand it) are indeed inheriting from ObjectDoesNotExist (common ancestor), but they are not the same class

Expected behavior

Do not raise this issue on common ancestor

pylint --version output

pylint 1.5.6,
astroid 1.4.6
Python 2.7.12 (default, Jun 29 2016, 14:05:02)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]

@safts
Copy link

safts commented Mar 10, 2017

I can reproduce this too.

@gbataille
Copy link
Author

Hey guys, cannot test yet on my full app because of a bug in pylint that prevents us from moving above 1.7.x

But thanks for the fix. I'll let you know if I experience further issues

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants