1111import logging
1212import shlex
1313import typing as t
14- import warnings
1514
1615from libtmux ._internal .query_list import QueryList
1716from libtmux .common import tmux_cmd
@@ -772,31 +771,10 @@ def split_window(
772771
773772 ``percent=25`` deprecated in favor of ``size="25%"``.
774773 """
775- warnings .warn (
776- "Window.split_window() is deprecated in favor of Window.split()" ,
777- category = DeprecationWarning ,
778- stacklevel = 2 ,
779- )
780-
781- if percent is not None :
782- # Deprecated in 3.1 in favor of -l
783- warnings .warn (
784- f'Deprecated in favor of size="{ str (percent ).rstrip ("%" )} %" '
785- '(using the "-l" flag).' ,
786- category = DeprecationWarning ,
787- stacklevel = 2 ,
788- )
789- if size is None :
790- size = f"{ str (percent ).rstrip ('%' )} %"
791-
792- return self .split (
793- target = target ,
794- start_directory = start_directory ,
795- attach = attach ,
796- direction = PaneDirection .Below if vertical else PaneDirection .Right ,
797- shell = shell ,
798- size = size ,
799- environment = environment ,
774+ raise exc .DeprecatedError (
775+ deprecated = "Window.split_window()" ,
776+ replacement = "Window.split()" ,
777+ version = "0.33.0" ,
800778 )
801779
802780 @property
@@ -809,15 +787,11 @@ def attached_pane(self) -> Pane | None:
809787
810788 Deprecated in favor of :meth:`.active_pane`.
811789 """
812- warnings . warn (
813- "Window.attached_pane() is deprecated in favor of Window.active_pane() " ,
814- category = DeprecationWarning ,
815- stacklevel = 2 ,
790+ raise exc . DeprecatedError (
791+ deprecated = "Window.attached_pane" ,
792+ replacement = "Window.active_pane" ,
793+ version = "0.31.0" ,
816794 )
817- panes = self .panes .filter (pane_active = "1" )
818- if len (panes ) > 0 :
819- return panes [0 ]
820- return None
821795
822796 def select_window (self ) -> Window :
823797 """Select window.
@@ -828,13 +802,11 @@ def select_window(self) -> Window:
828802
829803 Deprecated in favor of :meth:`.select()`.
830804 """
831- warnings . warn (
832- "Window.select_window() is deprecated in favor of Window.select ()" ,
833- category = DeprecationWarning ,
834- stacklevel = 2 ,
805+ raise exc . DeprecatedError (
806+ deprecated = "Window.select_window()" ,
807+ replacement = "Window.select()" ,
808+ version = "0.30.0" ,
835809 )
836- assert isinstance (self .window_index , str )
837- return self .session .select_window (self .window_index )
838810
839811 def kill_window (self ) -> None :
840812 """Kill the current :class:`Window` object. ``$ tmux kill-window``.
@@ -845,15 +817,11 @@ def kill_window(self) -> None:
845817
846818 Deprecated in favor of :meth:`.kill()`.
847819 """
848- warnings . warn (
849- "Window.kill_server() is deprecated in favor of Window.kill ()" ,
850- category = DeprecationWarning ,
851- stacklevel = 2 ,
820+ raise exc . DeprecatedError (
821+ deprecated = "Window.kill_window ()" ,
822+ replacement = "Window.kill()" ,
823+ version = "0.30.0" ,
852824 )
853- proc = self .cmd ("kill-window" )
854-
855- if proc .stderr :
856- raise exc .LibTmuxException (proc .stderr )
857825
858826 def set_window_option (
859827 self ,
@@ -867,12 +835,11 @@ def set_window_option(
867835 Deprecated by :meth:`Window.set_option()`.
868836
869837 """
870- warnings . warn (
871- "Window.set_window_option() is deprecated " ,
872- category = DeprecationWarning ,
873- stacklevel = 2 ,
838+ raise exc . DeprecatedError (
839+ deprecated = "Window.set_window_option()" ,
840+ replacement = "Window.set_option()" ,
841+ version = "0.26.0" ,
874842 )
875- return self .set_option (option = option , value = value )
876843
877844 def show_window_options (self , g : bool | None = False ) -> WindowOptionDict :
878845 """Show options for tmux window. Deprecated by :meth:`Window.show_options()`.
@@ -882,14 +849,10 @@ def show_window_options(self, g: bool | None = False) -> WindowOptionDict:
882849 Deprecated by :meth:`Window.show_options()`.
883850
884851 """
885- warnings .warn (
886- "Window.show_window_options() is deprecated" ,
887- category = DeprecationWarning ,
888- stacklevel = 2 ,
889- )
890- return self .show_options (
891- global_ = g or False ,
892- scope = OptionScope .Window ,
852+ raise exc .DeprecatedError (
853+ deprecated = "Window.show_window_options()" ,
854+ replacement = "Window.show_options()" ,
855+ version = "0.26.0" ,
893856 )
894857
895858 def show_window_option (
@@ -904,15 +867,10 @@ def show_window_option(
904867 Deprecated by :meth:`Window.show_option()`.
905868
906869 """
907- warnings .warn (
908- "Window.show_window_option() is deprecated" ,
909- category = DeprecationWarning ,
910- stacklevel = 2 ,
911- )
912- return self .show_option (
913- option = option ,
914- g = g ,
915- scope = OptionScope .Window ,
870+ raise exc .DeprecatedError (
871+ deprecated = "Window.show_window_option()" ,
872+ replacement = "Window.show_option()" ,
873+ version = "0.26.0" ,
916874 )
917875
918876 def get (self , key : str , default : t .Any | None = None ) -> t .Any :
@@ -924,12 +882,11 @@ def get(self, key: str, default: t.Any | None = None) -> t.Any:
924882 accessed via ``window.window_name``.
925883
926884 """
927- warnings . warn (
928- "Window.get() is deprecated " ,
929- category = DeprecationWarning ,
930- stacklevel = 2 ,
885+ raise exc . DeprecatedError (
886+ deprecated = "Window.get()" ,
887+ replacement = "direct attribute access (e.g., window.window_name)" ,
888+ version = "0.16.0" ,
931889 )
932- return getattr (self , key , default )
933890
934891 def __getitem__ (self , key : str ) -> t .Any :
935892 """Return item lookup by key. Deprecated in favor of attributes.
@@ -940,12 +897,11 @@ def __getitem__(self, key: str) -> t.Any:
940897 accessed via ``window.window_name``.
941898
942899 """
943- warnings . warn (
944- f"Item lookups, e.g. window[' { key } '] is deprecated " ,
945- category = DeprecationWarning ,
946- stacklevel = 2 ,
900+ raise exc . DeprecatedError (
901+ deprecated = "Window[ key] lookup " ,
902+ replacement = "direct attribute access (e.g., window.window_name)" ,
903+ version = "0.16.0" ,
947904 )
948- return getattr (self , key )
949905
950906 def get_by_id (self , pane_id : str ) -> Pane | None :
951907 """Return pane by id. Deprecated in favor of :meth:`.panes.get()`.
@@ -955,12 +911,11 @@ def get_by_id(self, pane_id: str) -> Pane | None:
955911 Deprecated by :meth:`.panes.get()`.
956912
957913 """
958- warnings . warn (
959- "Window.get_by_id() is deprecated " ,
960- category = DeprecationWarning ,
961- stacklevel = 2 ,
914+ raise exc . DeprecatedError (
915+ deprecated = "Window.get_by_id()" ,
916+ replacement = "Window.panes.get(pane_id=..., default=None)" ,
917+ version = "0.16.0" ,
962918 )
963- return self .panes .get (pane_id = pane_id , default = None )
964919
965920 def where (self , kwargs : dict [str , t .Any ]) -> list [Pane ]:
966921 """Filter through panes, return list of :class:`Pane`.
@@ -970,15 +925,11 @@ def where(self, kwargs: dict[str, t.Any]) -> list[Pane]:
970925 Deprecated by :meth:`.panes.filter()`.
971926
972927 """
973- warnings . warn (
974- "Window.where() is deprecated " ,
975- category = DeprecationWarning ,
976- stacklevel = 2 ,
928+ raise exc . DeprecatedError (
929+ deprecated = "Window.where()" ,
930+ replacement = "Window.panes.filter()" ,
931+ version = "0.16.0" ,
977932 )
978- try :
979- return self .panes .filter (** kwargs )
980- except IndexError :
981- return []
982933
983934 def find_where (self , kwargs : dict [str , t .Any ]) -> Pane | None :
984935 """Filter through panes, return first :class:`Pane`.
@@ -988,12 +939,11 @@ def find_where(self, kwargs: dict[str, t.Any]) -> Pane | None:
988939 Slated to be removed in favor of :meth:`.panes.get()`.
989940
990941 """
991- warnings . warn (
992- "Window.find_where() is deprecated " ,
993- category = DeprecationWarning ,
994- stacklevel = 2 ,
942+ raise exc . DeprecatedError (
943+ deprecated = "Window.find_where()" ,
944+ replacement = "Window.panes.get(default=None, **kwargs)" ,
945+ version = "0.16.0" ,
995946 )
996- return self .panes .get (default = None , ** kwargs )
997947
998948 def _list_panes (self ) -> list [PaneDict ]:
999949 """Return list of panes (deprecated in favor of :meth:`.panes`).
@@ -1003,12 +953,11 @@ def _list_panes(self) -> list[PaneDict]:
1003953 Slated to be removed in favor of :attr:`.panes`.
1004954
1005955 """
1006- warnings . warn (
1007- "Window._list_panes() is deprecated " ,
1008- category = DeprecationWarning ,
1009- stacklevel = 2 ,
956+ raise exc . DeprecatedError (
957+ deprecated = "Window._list_panes()" ,
958+ replacement = "Window.panes property" ,
959+ version = "0.16.0" ,
1010960 )
1011- return [pane .__dict__ for pane in self .panes ]
1012961
1013962 @property
1014963 def _panes (self ) -> list [PaneDict ]:
@@ -1019,8 +968,11 @@ def _panes(self) -> list[PaneDict]:
1019968 Slated to be removed in favor of :attr:`.panes`.
1020969
1021970 """
1022- warnings .warn ("_panes is deprecated" , category = DeprecationWarning , stacklevel = 2 )
1023- return self ._list_panes ()
971+ raise exc .DeprecatedError (
972+ deprecated = "Window._panes" ,
973+ replacement = "Window.panes property" ,
974+ version = "0.16.0" ,
975+ )
1024976
1025977 def list_panes (self ) -> list [Pane ]:
1026978 """Return list of :class:`Pane` for the window.
@@ -1030,12 +982,11 @@ def list_panes(self) -> list[Pane]:
1030982 Slated to be removed in favor of :attr:`.panes`.
1031983
1032984 """
1033- warnings . warn (
1034- " list_panes() is deprecated " ,
1035- category = DeprecationWarning ,
1036- stacklevel = 2 ,
985+ raise exc . DeprecatedError (
986+ deprecated = "Window. list_panes()" ,
987+ replacement = "Window.panes property" ,
988+ version = "0.16.0" ,
1037989 )
1038- return self .panes
1039990
1040991 @property
1041992 def children (self ) -> QueryList [Pane ]:
@@ -1046,9 +997,8 @@ def children(self) -> QueryList[Pane]:
1046997 Slated to be removed in favor of :attr:`.panes`.
1047998
1048999 """
1049- warnings . warn (
1050- "Window.children is deprecated " ,
1051- category = DeprecationWarning ,
1052- stacklevel = 2 ,
1000+ raise exc . DeprecatedError (
1001+ deprecated = "Window.children" ,
1002+ replacement = "Window.panes property" ,
1003+ version = "0.16.0" ,
10531004 )
1054- return self .panes
0 commit comments