Philipp Hörist pushed to branch master at gajim / gajim
Commits: 67ab4b10 by Philipp Hörist at 2022-12-19T16:25:33+01:00 cq: Use pyright specific ignore code
- - - - - 91889803 by Philipp Hörist at 2022-12-19T19:17:55+01:00 ci: Update ruff config
- - - - -
9 changed files:
- gajim/common/preview_helpers.py - gajim/common/settings.py - gajim/common/storage/archive.py - gajim/common/storage/base.py - gajim/common/storage/cache.py - gajim/common/storage/events.py - gajim/gtk/notification.py - gajim/gtk/util.py - pyproject.toml
Changes:
===================================== gajim/common/preview_helpers.py ===================================== @@ -278,7 +278,7 @@ def pixbuf_from_data(data: bytes) -> Optional[GdkPixbuf.Pixbuf]: # Fallback to Pillow input_file = BytesIO(data) image = Image.open(BytesIO(data)).convert('RGBA') - array = GLib.Bytes.new(image.tobytes()) # type: ignore + array = GLib.Bytes.new(image.tobytes()) # pyright: ignore width, height = image.size pixbuf = GdkPixbuf.Pixbuf.new_from_bytes(array, GdkPixbuf.Colorspace.RGB,
===================================== gajim/common/settings.py ===================================== @@ -258,7 +258,7 @@ def _load_app_overrides(self) -> None: def _namedtuple_factory(cursor: sqlite3.Cursor, row: tuple[Any, ...]) -> NamedTuple: fields = [col[0] for col in cursor.description] - return namedtuple('Row', fields)(*row) # type: ignore + return namedtuple('Row', fields)(*row) # pyright: ignore
def _connect_database(self) -> None: path = configpaths.get('SETTINGS')
===================================== gajim/common/storage/archive.py ===================================== @@ -191,7 +191,7 @@ def _namedtuple_factory(self,
assert cursor.description is not None fields = [col[0] for col in cursor.description] - Row = namedtuple('Row', fields) # type: ignore + Row = namedtuple('Row', fields) # pyright: ignore named_row = Row(*row) if 'additional_data' in fields: _dict = json.loads(named_row.additional_data or '{}')
===================================== gajim/common/storage/base.py ===================================== @@ -91,7 +91,7 @@ def _jid_converter(jid: bytes) -> JID:
def _convert_disco_info(disco_info: bytes) -> DiscoInfo: - return parse_disco_info(Iq(node=disco_info)) # type: ignore + return parse_disco_info(Iq(node=disco_info)) # pyright: ignore
def _adapt_disco_info(disco_info: DiscoInfo) -> str: @@ -112,7 +112,7 @@ def _convert_json(json_string: bytes) -> dict[str, Any]: class Encoder(json.JSONEncoder): def default(self, o: Any) -> Any: if isinstance(o, set): - return list(o) # type: ignore + return list(o) # pyright: ignore
if isinstance(o, JID): return {'__type': 'JID', 'value': str(o)}
===================================== gajim/common/storage/cache.py ===================================== @@ -87,7 +87,7 @@ class UnreadTableRow(NamedTuple): account: str jid: JID - count: int # type: ignore + count: int # pyright: ignore message_id: str timestamp: float
@@ -121,7 +121,7 @@ def _namedtuple_factory(cursor: sqlite3.Cursor,
assert cursor.description is not None fields = [col[0] for col in cursor.description] - Row = namedtuple('Row', fields) # type: ignore + Row = namedtuple('Row', fields) # pyright: ignore return Row(*row)
def _migrate(self) -> None: @@ -212,7 +212,7 @@ def get_last_disco_info(self, disco_info = self._disco_info_cache.get(jid) if disco_info is not None: max_timestamp = time.time() - max_age if max_age else 0 - if max_timestamp > disco_info.timestamp: # type: ignore + if max_timestamp > disco_info.timestamp: # pyright: ignore return None return disco_info
===================================== gajim/common/storage/events.py ===================================== @@ -88,7 +88,7 @@ def _namedtuple_factory(cursor: sqlite3.Cursor,
assert cursor.description is not None fields = [col[0] for col in cursor.description] - Row = namedtuple('Row', fields) # type: ignore + Row = namedtuple('Row', fields) # pyright: ignore return Row(*row)
def _migrate(self) -> None:
===================================== gajim/gtk/notification.py ===================================== @@ -299,7 +299,7 @@ def on_proxy_ready(_source: Gio.DBusProxy, res: Gio.AsyncResult) -> None: try: proxy = Gio.DBusProxy.new_finish(res) - self._caps = proxy.GetCapabilities() # type: ignore + self._caps = proxy.GetCapabilities() # pyright: ignore except GLib.Error as error: log.warning('Notifications D-Bus not available: %s', error) else:
===================================== gajim/gtk/util.py ===================================== @@ -506,7 +506,7 @@ def text_to_color(text: str) -> tuple[float, float, float]: background = (0, 0, 0) # RGB (0, 0, 0) black else: background = (1, 1, 1) # RGB (255, 255, 255) white - return nbxmpp.util.text_to_color(text, background) # type: ignore + return nbxmpp.util.text_to_color(text, background) # pyright: ignore
def get_contact_color(contact: types.ChatContactT @@ -566,7 +566,7 @@ def get_pixbuf_from_data(file_data: bytes) -> Optional[GdkPixbuf.Pixbuf]: 'convert avatar image using pillow') try: avatar = Image.open(BytesIO(file_data)).convert('RGBA') - array = GLib.Bytes.new(avatar.tobytes()) # type: ignore + array = GLib.Bytes.new(avatar.tobytes()) # pyright: ignore width, height = avatar.size pixbuf = GdkPixbuf.Pixbuf.new_from_bytes( array, GdkPixbuf.Colorspace.RGB, @@ -626,7 +626,7 @@ def load_pixbuf(path: Union[str, Path], log.debug('Error', exc_info=True) return None
- array = GLib.Bytes.new(avatar.tobytes()) # type: ignore + array = GLib.Bytes.new(avatar.tobytes()) # pyright: ignore width, height = avatar.size pixbuf = GdkPixbuf.Pixbuf.new_from_bytes( array, GdkPixbuf.Colorspace.RGB, True, @@ -681,7 +681,7 @@ def get_app_windows(account: str) -> list[Gtk.Window]: windows: list[Gtk.Window] = [] for win in app.app.get_windows(): if hasattr(win, 'account'): - if win.account == account: # type: ignore + if win.account == account: # pyright: ignore windows.append(win) return windows
@@ -695,11 +695,11 @@ def get_app_window(name: str, continue
if account is not None: - if account != win.account: # type: ignore + if account != win.account: # pyright: ignore continue
if jid is not None: - if jid != win.jid: # type: ignore + if jid != win.jid: # pyright: ignore continue return win return None @@ -728,7 +728,7 @@ def get_gtk_version() -> str: class EventHelper(CommonEventHelper): def __init__(self): CommonEventHelper.__init__(self) - self.connect('destroy', self.__on_destroy) # type: ignore + self.connect('destroy', self.__on_destroy) # pyright: ignore
def __on_destroy(self, *args: Any) -> None: self.unregister_events()
===================================== pyproject.toml ===================================== @@ -95,6 +95,7 @@ select = [ "C901", # mccabe # "D", # pydocstyle "E", # pycodestyle + # "EM", # flake8-errmsg # "ERA", # eradicate "F", # pyflakes # "FBT", # flake8-boolean-trap
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/57f18dc623f0b5b5b4179ef5d7ff70dd...