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

Unpin pytest-asyncio and update ruff config #1209

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
]

try:
import enchant
import enchant # noqa: F401

extensions += ["sphinxcontrib.spelling"]
except ImportError:
Expand Down
1 change: 0 additions & 1 deletion hatch_build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""A custom hatch build hook for ipykernel."""
import os
import shutil
import sys
from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
kernel_protocol_version_info,
version_info,
)
from .connect import *
from .connect import * # noqa: F403
2 changes: 1 addition & 1 deletion ipykernel/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def murmur2_x86(data, seed):
return h


convert_to_long_pathname = lambda filename: filename
convert_to_long_pathname = lambda filename: filename # noqa: E731

if sys.platform == "win32":
try:
Expand Down
18 changes: 9 additions & 9 deletions ipykernel/datapub.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

"""Publishing native (typically pickled) objects.
"""

import warnings

warnings.warn(
"ipykernel.datapub is deprecated. It has moved to ipyparallel.datapub",
DeprecationWarning,
stacklevel=2,
)

# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

from traitlets import Any, CBytes, Dict, Instance
from traitlets.config import Configurable

Expand All @@ -26,6 +20,12 @@

from jupyter_client.session import Session, extract_header

warnings.warn(
"ipykernel.datapub is deprecated. It has moved to ipyparallel.datapub",
DeprecationWarning,
stacklevel=2,
)


class ZMQDataPublisher(Configurable):
"""A zmq data publisher."""
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

try:
# This import is required to have the next ones working...
from debugpy.server import api
from debugpy.server import api # noqa: F401

from _pydevd_bundle import pydevd_frame_utils # isort: skip
from _pydevd_bundle.pydevd_suspended_frames import ( # isort: skip
Expand Down
10 changes: 5 additions & 5 deletions ipykernel/eventloops.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,24 +484,24 @@ def set_qt_api_env_from_gui(gui):
else:
if gui == "qt5":
try:
import PyQt5
import PyQt5 # noqa: F401

os.environ["QT_API"] = "pyqt5"
except ImportError:
try:
import PySide2
import PySide2 # noqa: F401

os.environ["QT_API"] = "pyside2"
except ImportError:
os.environ["QT_API"] = "pyqt5"
elif gui == "qt6":
try:
import PyQt6
import PyQt6 # noqa: F401

os.environ["QT_API"] = "pyqt6"
except ImportError:
try:
import PySide6
import PySide6 # noqa: F401

os.environ["QT_API"] = "pyside6"
except ImportError:
Expand All @@ -516,7 +516,7 @@ def set_qt_api_env_from_gui(gui):

# Do the actual import now that the environment variable is set to make sure it works.
try:
from IPython.external.qt_for_kernel import QtCore, QtGui
pass
except Exception as e:
# Clear the environment variable for the next attempt.
if "QT_API" in os.environ:
Expand Down
10 changes: 5 additions & 5 deletions ipykernel/gui/gtk3embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
import sys
import warnings

warnings.warn(
"The Gtk3 event loop for ipykernel is deprecated", category=DeprecationWarning, stacklevel=2
)

# Third-party
import gi

gi.require_version("Gdk", "3.0")
gi.require_version("Gtk", "3.0")
from gi.repository import GObject, Gtk
from gi.repository import GObject, Gtk # noqa: E402

warnings.warn(
"The Gtk3 event loop for ipykernel is deprecated", category=DeprecationWarning, stacklevel=2
)

# -----------------------------------------------------------------------------
# Classes and functions
Expand Down
8 changes: 4 additions & 4 deletions ipykernel/gui/gtkembed.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
import sys
import warnings

warnings.warn(
"The Gtk3 event loop for ipykernel is deprecated", category=DeprecationWarning, stacklevel=2
)

# Third-party
import gobject
import gtk

warnings.warn(
"The Gtk3 event loop for ipykernel is deprecated", category=DeprecationWarning, stacklevel=2
)

# -----------------------------------------------------------------------------
# Classes and functions
# -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ async def do_execute(
should_run_async = shell.should_run_async
accepts_params = _accepts_parameters(run_cell, ["cell_id"])
else:
should_run_async = lambda cell: False # noqa: ARG005
should_run_async = lambda cell: False # noqa: ARG005, E731
# older IPython,
# use blocking run_cell and wrap it in coroutine

Expand Down
3 changes: 1 addition & 2 deletions ipykernel/kernelspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from jupyter_client.kernelspec import KernelSpecManager
from traitlets import Unicode
from traitlets.config import Application

try:
from .debugger import _is_debugpy_available
Expand Down Expand Up @@ -171,8 +172,6 @@ def install(

# Entrypoint

from traitlets.config import Application


class InstallIPythonKernelSpecApp(Application):
"""Dummy app wrapping argparse"""
Expand Down
18 changes: 8 additions & 10 deletions ipykernel/pickleutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@

# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import typing
import warnings

warnings.warn(
"ipykernel.pickleutil is deprecated. It has moved to ipyparallel.",
DeprecationWarning,
stacklevel=2,
)

import copy
import pickle
import sys
import typing
import warnings
from types import FunctionType

# This registers a hook when it's imported
from ipyparallel.serialize import codeutil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this "dead code" side-effect is showing up here:

https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=885003&view=logs&j=a70f640f-cc53-5cd3-6cdc-236a1aa90802&t=6119ccbe-9301-594f-7c27-f792b80a7fcc&l=1235

_______________________________ test_no_closure _______________________________

    def test_no_closure():
        @interactive
        def foo():
            a = 5
            return a
    
>       pfoo = dumps(foo)

tests\test_pickleutil.py:28: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

obj = <function test_no_closure.<locals>.foo at 0x0000018BD7A07A60>

    def dumps(obj):
>       return pickle.dumps(can(obj))
E       TypeError: cannot pickle code objects


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, good catch!

from traitlets.log import get_logger
from traitlets.utils.importstring import import_item

warnings.warn(
"ipykernel.pickleutil is deprecated. It has moved to ipyparallel.",
DeprecationWarning,
stacklevel=2,
)

buffer = memoryview
class_type = type

Expand Down
2 changes: 1 addition & 1 deletion ipykernel/pylab/backend_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import warnings

from matplotlib_inline.backend_inline import * # type:ignore[import-untyped] # analysis: ignore
from matplotlib_inline.backend_inline import * # type:ignore[import-untyped] # noqa: F403 # analysis: ignore

warnings.warn(
"`ipykernel.pylab.backend_inline` is deprecated, directly "
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/pylab/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import warnings

from matplotlib_inline.config import * # type:ignore[import-untyped] # analysis: ignore
from matplotlib_inline.config import * # type:ignore[import-untyped] # noqa: F403 # analysis: ignore

warnings.warn(
"`ipykernel.pylab.config` is deprecated, directly use `matplotlib_inline.config`",
Expand Down
15 changes: 7 additions & 8 deletions ipykernel/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,8 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

import warnings

warnings.warn(
"ipykernel.serialize is deprecated. It has moved to ipyparallel.serialize",
DeprecationWarning,
stacklevel=2,
)

import pickle
import warnings
from itertools import chain

try:
Expand Down Expand Up @@ -41,6 +34,12 @@

from jupyter_client.session import MAX_BYTES, MAX_ITEMS

warnings.warn(
"ipykernel.serialize is deprecated. It has moved to ipyparallel.serialize",
DeprecationWarning,
stacklevel=2,
)

# -----------------------------------------------------------------------------
# Serialization Functions
# -----------------------------------------------------------------------------
Expand Down
52 changes: 28 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test = [
"flaky",
"ipyparallel",
"pre-commit",
"pytest-asyncio==0.23.4",
"pytest-asyncio>=0.23.5",
"pytest-timeout"
]
cov = [
Expand Down Expand Up @@ -209,29 +209,29 @@ omit = [
line-length = 100

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
"NPY", # NumPy specific rules
"PD", # pandas-vet
"PYI", # flake8-pyi
extend-select = [
"B", # flake8-bugbear
"I", # isort
"ARG", # flake8-unused-arguments
"C4", # flake8-comprehensions
"EM", # flake8-errmsg
"ICN", # flake8-import-conventions
"G", # flake8-logging-format
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PTH", # flake8-use-pathlib
"RET", # flake8-return
"RUF", # Ruff-specific
"SIM", # flake8-simplify
"T20", # flake8-print
"UP", # pyupgrade
"YTT", # flake8-2020
"EXE", # flake8-executable
"NPY", # NumPy specific rules
"PD", # pandas-vet
"PYI", # flake8-pyi
]
ignore = [
"PLR", # Design related pylint codes
Expand Down Expand Up @@ -265,6 +265,9 @@ unfixable = [
"T201",
# Don't touch noqa lines
"RUF100",
# Don't touch imports
"F401",
"F403"
]

[tool.ruff.lint.per-file-ignores]
Expand All @@ -277,6 +280,7 @@ unfixable = [
# B018 Found useless expression. Either assign it to a variable or remove it.
# S603 `subprocess` call: check for execution of untrusted input
"tests/*" = ["B011", "C408", "T201", "B007", "EM", "PTH", "PLW", "PLC1901", "B018", "S603", "ARG", "RET", "PGH"]
"*/__init__.py" = ["F401"]

[tool.interrogate]
ignore-init-module=true
Expand Down
Loading