Skip to content

Commit

Permalink
💬 upadte type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
arafune committed Oct 10, 2023
1 parent ee98751 commit 27475f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 4 additions & 4 deletions arpes/utilities/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ def get_recent_history(n_items: int = 10) -> list[str]:
from IPython.core.interactiveshell import InteractiveShell

ipython = get_ipython()

assert isinstance(ipython, InteractiveShell)
return [
_[-1] for _ in list(ipython.history_manager.get_tail(n=n_items, include_latest=True))
]
except (ImportError, AttributeError):
except (ImportError, AttributeError, AssertionError):
return ["No accessible history."]


Expand All @@ -134,7 +134,7 @@ def get_recent_logs(n_bytes: int = 1000) -> list[str]:
from IPython.core.interactiveshell import InteractiveShell

ipython = get_ipython()

assert isinstance(ipython, InteractiveShell)
if arpes.config.CONFIG["LOGGING_STARTED"]:
logging_file = arpes.config.CONFIG["LOGGING_FILE"]
assert isinstance(logging_file, str | Path)
Expand All @@ -150,7 +150,7 @@ def get_recent_logs(n_bytes: int = 1000) -> list[str]:
final_cell = ipython.history_manager.get_tail(n=1, include_latest=True)[0][-1]
return [_.decode() for _ in lines] + [final_cell]

except (ImportError, AttributeError):
except (ImportError, AttributeError, AssertionError):
pass

return ["No logging available. Logging is only available inside Jupyter."]
13 changes: 7 additions & 6 deletions tests/test_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
from PySide6 import QtCore
from pytestqt.qt_compat import qt_api
from pytestqt.qtbot import QtBot

import pytest
from arpes.io import example_data

if TYPE_CHECKING:
from arpes.plotting.qt_tool import QtTool


@pytest.mark.skip()
def test_open_qt_tool_and_basic_functionality(qtbot: QtBot) -> None:
"""Test for qt_tool and it's basic functionality.
Expand All @@ -37,14 +38,14 @@ def test_open_qt_tool_and_basic_functionality(qtbot: QtBot) -> None:

# Check cursor info
assert app.owner.context["cursor"] == [120, 120]
qtbot.keyPress(app.owner.cw, QtCore.Qt.Key_Left)
qtbot.keyPress(app.owner.cw, QtCore.Qt.Key.Key_Left)
assert app.owner.context["cursor"] == [118, 120]
qtbot.keyPress(app.owner.cw, QtCore.Qt.Key_Up)
qtbot.keyPress(app.owner.cw, QtCore.Qt.Key.Key_Up)
assert app.owner.context["cursor"] == [118, 122]
qtbot.keyPress(app.owner.cw, QtCore.Qt.Key_Right)
qtbot.keyPress(app.owner.cw, QtCore.Qt.Key_Right)
qtbot.keyPress(app.owner.cw, QtCore.Qt.Key.Key_Right)
qtbot.keyPress(app.owner.cw, QtCore.Qt.Key.Key_Right)
assert app.owner.context["cursor"] == [122, 122]
qtbot.keyPress(app.owner.cw, QtCore.Qt.Key_Down)
qtbot.keyPress(app.owner.cw, QtCore.Qt.Key.Key_Down)
assert app.owner.context["cursor"] == [122, 120]

app.owner.close()

0 comments on commit 27475f7

Please sign in to comment.