Просмотр исходного кода

chore(lint): fix Ruff errors in query_gsquery.py (#5003)

- Add .github/linters/.ruff.toml with line-length 88 to match Black.
  Super Linter's default Ruff config uses 120, so ruff format and Black
  disagreed about the same file. target-version py38 keeps Ruff from
  suggesting changes that need a newer Python than Ubuntu 20.04 has.
- query_gsquery.py: make executable (EXE001), drop the redundant coding
  declaration (UP009) and an empty comment (PLR2044), and catch OSError
  instead of its alias socket.error (UP024).
Daniel Gibbs 1 неделя назад
Родитель
Сommit
f098804d4d
2 измененных файлов с 12 добавлено и 3 удалено
  1. 11 0
      .github/linters/.ruff.toml
  2. 1 3
      lgsm/modules/query_gsquery.py

+ 11 - 0
.github/linters/.ruff.toml

@@ -0,0 +1,11 @@
+# Store the cache in a temporary location
+cache-dir = "/tmp/.ruff_cache"
+
+# Same as Black
+line-length = 88
+
+# Oldest Python on supported distros (Ubuntu 20.04)
+target-version = "py38"
+
+[lint]
+ignore = ["E203"]

+ 1 - 3
lgsm/modules/query_gsquery.py

@@ -1,5 +1,4 @@
 #! /usr/bin/env python3
-# -*- coding: utf-8 -*-
 # LinuxGSM query_gsquery.py module
 # Author: Daniel Gibbs
 # Contributors: https://linuxgsm.com/contrib
@@ -65,7 +64,6 @@ class GSQuery:
         """Create a query instance from parsed CLI args."""
 
         self.argument = arguments
-        #
         if self.argument.engine in self.sourcequery:
             self.query_prompt_string = b"\xff\xff\xff\xffTSource Engine Query\0"
         elif self.argument.engine in self.idtech2query:
@@ -135,7 +133,7 @@ class GSQuery:
         # Receive.
         try:
             self.response = connection.recv(self.default_buffer_length)
-        except socket.error:
+        except OSError:
             self.fatal_error("Unable to receive", 2)
         connection.close()
         # Response.