From 03d7b911b65be4556193d5c1f17797c0f4865a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pr=C3=BCsse?= Date: Tue, 31 Oct 2023 16:25:15 -0300 Subject: [PATCH] Use the builtin `nullcontext` ASIM-5273 --- src/qmxgraph/api.py | 12 +----------- tests/test_qt_js_integration.py | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/qmxgraph/api.py b/src/qmxgraph/api.py index 3769ada4..a03d3bf9 100644 --- a/src/qmxgraph/api.py +++ b/src/qmxgraph/api.py @@ -1,7 +1,7 @@ -import sys import textwrap import weakref from contextlib import contextmanager +from contextlib import nullcontext from typing import Any from typing import Generator from typing import List @@ -1020,13 +1020,3 @@ def handle_message(msg_type, context, message): yield messages finally: qInstallMessageHandler(previous_handler) - - -if sys.version_info[:] < (3, 7): - - @contextmanager - def nullcontext(enter_result=None): - yield enter_result - -else: - from contextlib import nullcontext diff --git a/tests/test_qt_js_integration.py b/tests/test_qt_js_integration.py index d84785b2..9921e7f7 100644 --- a/tests/test_qt_js_integration.py +++ b/tests/test_qt_js_integration.py @@ -1,11 +1,11 @@ import json import re import textwrap +from contextlib import nullcontext from functools import partial import pytest import pytestqt.exceptions -from _pytest.compat import nullcontext from PyQt5.QtCore import QByteArray from PyQt5.QtCore import QDataStream from PyQt5.QtCore import QIODevice