Skip to content

fix ABCMeta not subscriptable #44

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 18 additions & 2 deletions vspreview/toolbars/pipette.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ctypes
import logging
from typing import cast, Dict, List, TypeVar, Union
import sys
from typing import cast, Dict, List, TypeVar, Union, TYPE_CHECKING
from weakref import WeakKeyDictionary

from PyQt5 import Qt
Expand All @@ -14,6 +15,21 @@
Number = TypeVar('Number', int, float)


if TYPE_CHECKING:
BaseWeakKeyDictionary = WeakKeyDictionary
else:
if sys.version_info < (3, 9):
class _WeakKeyDictionary(WeakKeyDictionary):
def __getitem__(self, key):
print(key)
if isinstance(key, Output):
return super().__getitem__(key)
return self.__class__
BaseWeakKeyDictionary = _WeakKeyDictionary()
else:
BaseWeakKeyDictionary = WeakKeyDictionary


class PipetteToolbar(AbstractToolbar):
__slots__ = (
'color_view', 'outputs', 'position', 'pos_fmt', 'tracking',
Expand Down Expand Up @@ -43,7 +59,7 @@ def __init__(self, main: AbstractMainWindow) -> None:
self.src_max_val: Union[int, float] = 2**8 - 1
self.src_dec_fmt = '{:3d}'
self.src_norm_fmt = '{:0.5f}'
self.outputs = WeakKeyDictionary[Output, vs.VideoNode]()
self.outputs = BaseWeakKeyDictionary[Output, vs.VideoNode]()
self.tracking = False

set_qobject_names(self)
Expand Down