-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix crash in no-member
check for C extensions
#6235
Conversation
Pull Request Test Coverage Report for Build 2117322267
π - Coveralls |
c-extension-no-member
checkno-member
check for C extensions
Co-authored-by: Pierre Sassoulas <[email protected]>
I spent a cycle trying to figure out how to test this. We would need a package with a C extension without ballooning our test dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a suggestion, we could also post the URL to this comment. I think adding the pragma no cover is important if we're voluntarily not testing the code.
for more information, see https://pre-commit.ci
For future reference, here is a test case for diff --git a/requirements_test.txt b/requirements_test.txt
index 2e35f584..04aac371 100644
--- a/requirements_test.txt
+++ b/requirements_test.txt
@@ -6,6 +6,7 @@ pre-commit~=2.17;python_full_version>="3.6.2"
tbump~=6.6.0
contributors-txt>=0.7.3
pyenchant~=3.2
+PyQt6~=6.2
pytest-cov~=3.0
pytest-profiling~=1.7
pytest-xdist~=2.5
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/functional/n/no/no_member_c_extension.py b/tests/functional/n/no/no_member_c_extension.py
new file mode 100644
index 00000000..e09f7d03
--- /dev/null
+++ b/tests/functional/n/no/no_member_c_extension.py
@@ -0,0 +1,9 @@
+"""Regression test for https://github.com/PyCQA/pylint/issues/6221"""
+
+# local import that creates ambiguity with test requirement PyQt6
+# PyQt6 has the name printsupport
+from tests.input.qt6 import printsupport
+
+dialog = printsupport.QPrintPreviewDialog
+# paintRequested (nodes.FunctionDef) is the owner of the name connect, not the module
+dialog.paintRequested.connect()
diff --git a/tests/functional/n/no/no_member_c_extension.rc b/tests/functional/n/no/no_member_c_extension.rc
new file mode 100644
index 00000000..b3320786
--- /dev/null
+++ b/tests/functional/n/no/no_member_c_extension.rc
@@ -0,0 +1,2 @@
+[MASTER]
+extension-pkg-allow-list=PyQt6.QtPrintSupport
diff --git a/tests/input/qt6.py b/tests/input/qt6.py
new file mode 100644
index 00000000..44312ea8
--- /dev/null
+++ b/tests/input/qt6.py
@@ -0,0 +1 @@
+from PyQt6 import QtPrintSupport as printsupport |
Hold up, there's a deeper root cause that's fixable in the astroid brain for qt. |
Superseded by pylint-dev/astroid#1505 |
But isn't it a good thing that we do not crash in case there's an issue in a brain or in astroid's analysis ? |
I guess my thought was that we don't want to silence programming errors. Someone could contribute a broken brain and not realize it if we're just catching errors in pylint. |
I agree we should not silence our own errors. But on the other hand, the brain was contributed with an error and we have a really hard time reproducing the bug, even adding an automated test to check the fix we added is complicated. What could make sure that we do not contribute faulty brains in the future ? (Maybe better typing in astroid? A lot was already done for typing but it's not possible to activate mypy at this point in time) |
I hear that astroid is not ready for comprehensive type-checking. Maybe we can start turning it on file by file, or just in the brains and work our way toward the center. That's what I'm doing in another library I work on (start on edges). I added some typing to the astroid PR that will raise mypy errors without the fix. |
It's closer and closer though. |
Type of Changes
Description
Closes #6221. Regression in 129c730 (unreleased 2.14)