Explain: in try block with 'except ImportError' should also be defined in except block Follow
Hi
I have some code like this
try:
import psycopg2
import psycopg2.extras
except ImportError:
pass
The 2 import lines trigger Pycharm to issue the warning below; could someone explain what this means please? And ideally a way of avoiding the warning
'psycopg2' in try block with 'except ImportError' should also be defined in except block
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
Thanks
I have some code like this
try:
import psycopg2
import psycopg2.extras
except ImportError:
pass
The 2 import lines trigger Pycharm to issue the warning below; could someone explain what this means please? And ideally a way of avoiding the warning
'psycopg2' in try block with 'except ImportError' should also be defined in except block
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
Thanks
Please sign in to leave a comment.
is there anyone know what's wrong with it, i encounter the same issue,
ImportError: notifications are not supported, can't import necessary library
Please share a screenshot showing the issue and your code for a better understanding.
The code provided in the original issue description doesn't trigger any warnings in my environment.
I just found the same issue. Here's a screenshot from my example:
@Trevor Smith
I can't reproduce it with your code snippet for some reason.
Does it reproduce in a new project?