Philipp Hörist pushed to branch master at gajim / gajim

Commits:

8 changed files:

Changes:

  • .pre-commit-config.yaml
    1 1
     repos:
    
    2 2
       - repo: https://github.com/charliermarsh/ruff-pre-commit
    
    3
    -    rev: v0.0.259
    
    3
    +    rev: v0.0.270
    
    4 4
         hooks:
    
    5 5
           - id: ruff
    
    6 6
             exclude: ".githooks/"
    

  • gajim/common/configpaths.py
    ... ... @@ -113,7 +113,7 @@ def __init__(self) -> None:
    113 113
                 else:
    
    114 114
                     # Documents and Settings\[User Name]\Application Data\Gajim
    
    115 115
                     self.config_root = self.cache_root = self.data_root = \
    
    116
    -                    Path(os.environ['appdata']) / 'Gajim'
    
    116
    +                    Path(os.environ['APPDATA']) / 'Gajim'
    
    117 117
             else:
    
    118 118
                 self.config_root = Path(GLib.get_user_config_dir()) / 'gajim'
    
    119 119
                 self.cache_root = Path(GLib.get_user_cache_dir()) / 'gajim'
    

  • gajim/common/helpers.py
    ... ... @@ -1109,7 +1109,7 @@ def open_file_uri(uri: str) -> None:
    1109 1109
             if sys.platform != 'win32':
    
    1110 1110
                 Gio.AppInfo.launch_default_for_uri(uri)
    
    1111 1111
             else:
    
    1112
    -            os.startfile(uri)
    
    1112
    +            os.startfile(uri)  # noqa: S606
    
    1113 1113
         except Exception as err:
    
    1114 1114
             log.info("Couldn't open file URI %s: %s", uri, err)
    
    1115 1115
     
    

  • gajim/common/jingle_rtp.py
    ... ... @@ -24,7 +24,6 @@
    24 24
     from typing import Optional
    
    25 25
     
    
    26 26
     import logging
    
    27
    -import os
    
    28 27
     import socket
    
    29 28
     from collections import deque
    
    30 29
     from datetime import datetime
    
    ... ... @@ -40,6 +39,7 @@
    40 39
         pass
    
    41 40
     
    
    42 41
     from gajim.common import app
    
    42
    +from gajim.common import configpaths
    
    43 43
     from gajim.common.i18n import _
    
    44 44
     from gajim.common.jingle_content import contents
    
    45 45
     from gajim.common.jingle_content import JingleContent
    
    ... ... @@ -571,20 +571,11 @@ def do_setup(self,
    571 571
             self.pipeline.set_state(Gst.State.PLAYING)
    
    572 572
     
    
    573 573
             if log.getEffectiveLevel() == logging.DEBUG:
    
    574
    -            # Use 'export GST_DEBUG_DUMP_DOT_DIR=/tmp/' before starting Gajim
    
    575 574
                 timestamp = datetime.now().strftime('%m-%d-%Y-%H-%M-%S')
    
    576 575
                 name = f'video-graph-{timestamp}'
    
    577
    -            debug_dir = os.environ.get('GST_DEBUG_DUMP_DOT_DIR')
    
    578
    -            name_dot = f'{debug_dir}/{name}.dot'
    
    579
    -            name_png = f'{debug_dir}/{name}.png'
    
    576
    +            filename = configpaths.get('DEBUG') / f'{name}.dot'
    
    580 577
                 Gst.debug_bin_to_dot_file(
    
    581
    -                self.pipeline, Gst.DebugGraphDetails.ALL, name)
    
    582
    -            if debug_dir:
    
    583
    -                try:
    
    584
    -                    os.system(f'dot -Tpng {name_dot} > {name_png}')
    
    585
    -                except Exception:
    
    586
    -                    log.debug('Could not save pipeline graph. Make sure '
    
    587
    -                              'graphviz is installed.')
    
    578
    +                self.pipeline, Gst.DebugGraphDetails.ALL, str(filename))
    
    588 579
     
    
    589 580
         @staticmethod
    
    590 581
         def get_fallback_src() -> Optional[Gst.Bin]:
    

  • gajim/common/modules/contacts.py
    ... ... @@ -421,8 +421,8 @@ def iter_resources(self) -> Iterator[ResourceContact]:
    421 421
         @property
    
    422 422
         def is_available(self) -> bool:
    
    423 423
             # pylint: disable=R1729
    
    424
    -        return any([contact.is_available for contact
    
    425
    -                    in self._resources.values()])
    
    424
    +        return any(contact.is_available for contact
    
    425
    +                   in self._resources.values())
    
    426 426
     
    
    427 427
         @property
    
    428 428
         def show(self):
    

  • gajim/gtk/preview_audio_visualizer.py
    ... ... @@ -126,8 +126,8 @@ def _process_samples(self) -> None:
    126 126
                 samples = self._samples
    
    127 127
     
    
    128 128
             # Normalize both channels using the same scale
    
    129
    -        max_elem = max(max(samples))
    
    130
    -        min_elem = min(min(samples))
    
    129
    +        max_elem = max(max(samples))  # noqa: PLW3301
    
    130
    +        min_elem = min(min(samples))  # noqa: PLW3301
    
    131 131
             delta = max_elem - min_elem
    
    132 132
             if delta > 0:
    
    133 133
                 self._samples = [
    

  • launch.py
    ... ... @@ -2,16 +2,14 @@
    2 2
     
    
    3 3
     import subprocess
    
    4 4
     
    
    5
    -from gajim import gajim
    
    5
    +import gajim
    
    6
    +from gajim.gajim import main
    
    6 7
     
    
    7 8
     try:
    
    8
    -    p = subprocess.Popen('git rev-parse --short=12 HEAD', shell=True,
    
    9
    -                         stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
    
    10
    -    node = p.communicate()[0]
    
    11
    -    if node:
    
    12
    -        import gajim as g
    
    13
    -        g.__version__ += '+' + node.decode('utf-8').strip()
    
    9
    +    res = subprocess.check_output(
    
    10
    +        ['git', 'rev-parse', '--short=12', 'HEAD'])  # noqa: S603, S607
    
    11
    +    gajim.__version__ += f'+{res.decode().strip()}'
    
    14 12
     except Exception:
    
    15 13
         pass
    
    16 14
     
    
    17
    -gajim.main()
    15
    +main()

  • pyproject.toml
    ... ... @@ -201,6 +201,7 @@ ignore = [
    201 201
       "N806",   # Variable should be lower case
    
    202 202
       "N817",   # CamelCase imported as acronym
    
    203 203
       "N818",   # Exception name should be named with an Error suffix
    
    204
    +  "PGH003", # Use specific rule codes when ignoring type issues
    
    204 205
       "PLC1901",# Expression can be simplified to x as an empty string is falsey
    
    205 206
       "PLR0911",# Too many return statements
    
    206 207
       "PLR0912",# Too many branches
    
    ... ... @@ -267,6 +268,10 @@ target-version = "py310"
    267 268
     "test/*" = ["E402"]
    
    268 269
     "test/common/test_styling.py" = ["RUF001", "E501"]
    
    269 270
     "test/common/test_regex.py" = ["RUF001"]
    
    271
    +"pep517build/*" = ["S603", "S607"]
    
    272
    +"mac/*" = ["S603", "S607"]
    
    273
    +"win/*" = ["S603", "S607"]
    
    274
    +"scripts/*" = ["S603", "S607"]
    
    270 275
     
    
    271 276
     [tool.ruff.mccabe]
    
    272 277
     max-complexity = 15