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

Fixes #4040, #5378 - signal has no connect member #1654

Merged
merged 19 commits into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7ac6c4c
feat(.gitignore): add `.venv/` to `.gitignore`
adamgranthendry Jun 22, 2022
1fde25b
fix(setup.cfg): remove `enable_error_code`
adamgranthendry Jun 22, 2022
060b4b2
fix(brain_qt): fix signal has no `connect` member
adamgranthendry Jun 23, 2022
f1e0c46
feat(changelog): add contribution to changelog
adamgranthendry Jun 23, 2022
6596118
fix(formatting): correct formatter auto changes
adamgranthendry Jun 23, 2022
7d6d847
fix(setup.cfg): Remove accidental mypy addition
adamgranthendry Jun 23, 2022
27c6099
feat(test): add regression test for #4040 and #5378
adamgranthendry Jun 24, 2022
53d503b
fix(docstring): fix docstring for added method
adamgranthendry Jun 24, 2022
6b696fe
fix(test): skip test for python 3.11
adamgranthendry Jun 24, 2022
de89a62
fix(pip): add py311 version constraint for PySide
adamgranthendry Jun 24, 2022
085dc9e
fix(test): remove skipif for py311
adamgranthendry Jun 24, 2022
f4773fa
Refactor
DanielNoord Jun 24, 2022
dd2aae8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 24, 2022
4220d0f
Update astroid/brain/brain_qt.py
DanielNoord Jun 24, 2022
9b6e097
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 24, 2022
b923b68
fix(test): correct `HAS_PYQT6` for original test
adamgranthendry Jun 24, 2022
5cb2572
fix(test): remove test and replace with no cover
adamgranthendry Jun 24, 2022
29df6c1
Last changes
DanielNoord Jun 25, 2022
246f93e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ astroid.egg-info/
.pytest_cache/
.mypy_cache/
venv
doc/_build/
adam-grant-hendry marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ What's New in astroid 2.12.0?
=============================
Release date: TBA

* Fix signal has no ``connect`` member for PySide2 5.15.2+ and PySide6

Closes #4040, #5378

* ``astroid`` now requires Python 3.7.2 to run.

* Avoid setting a Call as a base for classes created using ``six.with_metaclass()``.
Expand Down
16 changes: 11 additions & 5 deletions astroid/brain/brain_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
from astroid.manager import AstroidManager


def _looks_like_signal(node, signal_name="pyqtSignal"):
if "__class__" in node.instance_attrs:
def _looks_like_signal(
node: nodes.FunctionDef, signal_name: str = "pyqtSignal"
) -> bool: # pragma: no cover
"""Detect a Signal node."""
klasses = node.instance_attrs.get("__class__", [])
# On PySide2 or PySide6 (since Qt 5.15.2) the Signal class changed locations
if node.qname().partition(".")[0] in {"PySide2", "PySide6"}:
return any(cls.qname() == "Signal" for cls in klasses)
if klasses:
try:
cls = node.instance_attrs["__class__"][0]
return cls.name == signal_name
return klasses[0].name == signal_name
except AttributeError:
# return False if the cls does not have a name attribute
pass
Expand Down Expand Up @@ -79,4 +85,4 @@ def emit(self, signal): pass
nodes.ClassDef,
transform_pyside_signal,
lambda node: node.qname() in {"PySide.QtCore.Signal", "PySide2.QtCore.Signal"},
)
) # pragma: no cover
4 changes: 4 additions & 0 deletions script/.contributors_aliases.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,9 @@
"[email protected]": {
"mails": ["[email protected]", "[email protected]"],
"name": "Ville Skyttä"
},
"[email protected]": {
"mails": ["[email protected]"],
"name": "Adam Hendry"
adam-grant-hendry marked this conversation as resolved.
Show resolved Hide resolved
}
}
9 changes: 7 additions & 2 deletions tests/unittest_brain_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
HAS_PYQT6 = find_spec("PyQt6")


@pytest.mark.skipif(HAS_PYQT6 is None, reason="This test requires the PyQt6 library.")
@pytest.mark.skipif(
HAS_PYQT6 is None,
reason="These tests require the PyQt6 library.",
)
class TestBrainQt:
AstroidManager.brain["extension_package_whitelist"] = {"PyQt6"}
AstroidManager.brain["extension_package_whitelist"] = {
"PyQt6",
}

@staticmethod
def test_value_of_lambda_instance_attrs_is_list():
Expand Down