Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Backport PR #24197 on branch v3.6.x (Properly set and inherit backend_version.) #24237

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

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
13 changes: 7 additions & 6 deletions lib/matplotlib/backends/_backend_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@
raise ImportError("Gtk-based backends require cairo") from e

_log = logging.getLogger(__name__)

backend_version = "%s.%s.%s" % (
Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())

# Placeholder
_application = None
_application = None # Placeholder


def _shutdown_application(app):
Expand Down Expand Up @@ -305,6 +300,12 @@ def trigger(self, *args):


class _BackendGTK(_Backend):
backend_version = "%s.%s.%s" % (
Gtk.get_major_version(),
Gtk.get_minor_version(),
Gtk.get_micro_version(),
)

@staticmethod
def mainloop():
global _application
Expand Down
4 changes: 1 addition & 3 deletions lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@


_log = logging.getLogger(__name__)

backend_version = tk.TkVersion

cursord = {
cursors.MOVE: "fleur",
cursors.HAND: "hand2",
Expand Down Expand Up @@ -1027,6 +1024,7 @@ def trigger(self, *args):

@_Backend.export
class _BackendTk(_Backend):
backend_version = tk.TkVersion
FigureManager = FigureManagerTk

@staticmethod
Expand Down
4 changes: 1 addition & 3 deletions lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
from matplotlib.backends._backend_agg import RendererAgg as _RendererAgg


backend_version = 'v2.2'


def get_hinting_flag():
mapping = {
'default': LOAD_DEFAULT,
Expand Down Expand Up @@ -563,5 +560,6 @@ def print_webp(self, filename_or_obj, *, pil_kwargs=None):

@_Backend.export
class _BackendAgg(_Backend):
backend_version = 'v2.2'
FigureCanvas = FigureCanvasAgg
FigureManager = FigureManagerBase
4 changes: 1 addition & 3 deletions lib/matplotlib/backends/backend_cairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
from matplotlib.transforms import Affine2D


backend_version = cairo.version


def _append_path(ctx, path, transform, clip=None):
for points, code in path.iter_segments(
transform, remove_nans=True, clip=clip):
Expand Down Expand Up @@ -548,5 +545,6 @@ def set_context(self, ctx):

@_Backend.export
class _BackendCairo(_Backend):
backend_version = cairo.version
FigureCanvas = FigureCanvasCairo
FigureManager = FigureManagerBase
1 change: 0 additions & 1 deletion lib/matplotlib/backends/backend_gtk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
_BackendGTK, _FigureManagerGTK, _NavigationToolbar2GTK,
TimerGTK as TimerGTK3,
)
from ._backend_gtk import backend_version # noqa: F401 # pylint: disable=W0611


_log = logging.getLogger(__name__)
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/backends/backend_gtk4.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
_BackendGTK, _FigureManagerGTK, _NavigationToolbar2GTK,
TimerGTK as TimerGTK4,
)
from ._backend_gtk import backend_version # noqa: F401 # pylint: disable=W0611


class FigureCanvasGTK4(FigureCanvasBase, Gtk.DrawingArea):
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
from matplotlib.backends.backend_mixed import MixedModeRenderer
from . import _backend_pdf_ps

_log = logging.getLogger(__name__)

backend_version = 'Level II'
_log = logging.getLogger(__name__)
debugPS = False


Expand Down Expand Up @@ -1364,4 +1363,5 @@ def pstoeps(tmpfile, bbox=None, rotated=False):

@_Backend.export
class _BackendPS(_Backend):
backend_version = 'Level II'
FigureCanvas = FigureCanvasPS
3 changes: 1 addition & 2 deletions lib/matplotlib/backends/backend_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
)


backend_version = __version__

# SPECIAL_KEYS are Qt::Key that do *not* return their Unicode name
# instead they have manually specified names.
SPECIAL_KEYS = {
Expand Down Expand Up @@ -1013,6 +1011,7 @@ def trigger(self, *args, **kwargs):

@_Backend.export
class _BackendQT(_Backend):
backend_version = __version__
FigureCanvas = FigureCanvasQT
FigureManager = FigureManagerQT

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


from .backend_qt import ( # noqa
backend_version, SPECIAL_KEYS,
SPECIAL_KEYS,
# Public API
cursord, _create_qApp, _BackendQT, TimerQT, MainWindow, FigureCanvasQT,
FigureManagerQT, ToolbarQt, NavigationToolbar2QT, SubplotToolQt,
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/backends/backend_qt5agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
backends._QT_FORCE_QT5_BINDING = True
from .backend_qtagg import ( # noqa: F401, E402 # pylint: disable=W0611
_BackendQTAgg, FigureCanvasQTAgg, FigureManagerQT, NavigationToolbar2QT,
backend_version, FigureCanvasAgg, FigureCanvasQT
)
FigureCanvasAgg, FigureCanvasQT)


@_BackendQTAgg.export
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_qtagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .backend_agg import FigureCanvasAgg
from .backend_qt import QtCore, QtGui, _BackendQT, FigureCanvasQT
from .backend_qt import ( # noqa: F401 # pylint: disable=W0611
FigureManagerQT, NavigationToolbar2QT, backend_version)
FigureManagerQT, NavigationToolbar2QT)


class FigureCanvasQTAgg(FigureCanvasAgg, FigureCanvasQT):
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
from matplotlib import _path
from matplotlib.transforms import Affine2D, Affine2DBase


_log = logging.getLogger(__name__)

backend_version = mpl.__version__

# ----------------------------------------------------------------------
# SimpleXMLWriter class
Expand Down Expand Up @@ -1426,4 +1426,5 @@ def draw(self):

@_Backend.export
class _BackendSVG(_Backend):
backend_version = mpl.__version__
FigureCanvas = FigureCanvasSVG