Fix whitespace issues detected by flake8 (#2652)

This commit also removes exclusions that are no longer needed.
This commit is contained in:
correctmost 2024-08-28 11:40:53 -04:00 committed by GitHub
parent 7b5f1f72f9
commit 62b4099c8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 141 additions and 127 deletions

View File

@ -1,11 +1,11 @@
[flake8]
count = True
# Several of the following could be autofixed or improved by running the code through psf/black
ignore = E123,E126,E128,E203,E227,E231,E261,E302,E402,E722,F541,W191,W292,W293,W503,W504
ignore = E123,E128,E722,F541,W191,W503,W504
max-complexity = 40
max-line-length = 236
max-line-length = 220
show-source = True
statistics = True
builtins = _
per-file-ignores = __init__.py:F401,F403,F405 simple_menu.py:C901,W503 guided.py:C901 network_configuration.py:F821
exclude = .git,__pycache__,docs,actions-runner
per-file-ignores = __init__.py:F401
exclude = .git,__pycache__,build,docs,actions-runner

View File

@ -1,5 +1,5 @@
on: [ push, pull_request ]
name: flake8 linting (15 ignores)
name: flake8 linting (7 ignores)
jobs:
flake8:
runs-on: ubuntu-latest

View File

@ -27,7 +27,7 @@ The exceptions to PEP8 are:
* Archinstall uses [tabs instead of spaces](https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces) simply to make it
easier for non-IDE developers to navigate the code *(Tab display-width should be equal to 4 spaces)*. Exception to the
rule are comments that need fine-tuned indentation for documentation purposes.
* [Line length](https://www.python.org/dev/peps/pep-0008/#maximum-line-length) a maximum line length is enforced via flake8 with 236 characters
* [Line length](https://www.python.org/dev/peps/pep-0008/#maximum-line-length) a maximum line length is enforced via flake8 with 220 characters
* [Line breaks before/after binary operator](https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator)
is not enforced, as long as the style of line breaks is consistent within the same code block.
* Archinstall should always be saved with **Unix-formatted line endings** and no other platform-specific formats.

View File

@ -6,6 +6,7 @@ from archinstall.default_profiles.xorg import XorgProfile
if TYPE_CHECKING:
_: Any
class CosmicProfile(XorgProfile):
def __init__(self) -> None:
super().__init__('cosmic-epoch', ProfileType.DesktopEnv, description='', advanced=True)

View File

@ -6,6 +6,7 @@ from archinstall.default_profiles.xorg import XorgProfile
if TYPE_CHECKING:
_: Any
class PlasmaProfile(XorgProfile):
def __init__(self) -> None:
super().__init__('KDE Plasma', ProfileType.DesktopEnv, description='')

View File

@ -40,6 +40,7 @@ class GreeterType(Enum):
if '--advanced' in sys.argv:
CosmicSession = "cosmic-greeter"
class SelectResult(Enum):
NewSelection = auto()
SameSelection = auto()

View File

@ -80,6 +80,7 @@ def jsonify(obj: Any, safe: bool = True) -> Any:
return obj
class JSON(json.JSONEncoder, json.JSONDecoder):
"""
A safe JSON encoder that will omit private information in dicts (starting with !)

View File

@ -140,6 +140,7 @@ class GfxDriver(Enum):
return packages
class _SysInfo:
def __init__(self) -> None:
pass

View File

@ -87,6 +87,7 @@ class MirrorStatusEntryV3(pydantic.BaseModel):
debug(f"Loaded mirror {self._hostname}" + (f" with current score of {round(self.score)}" if self.score else ''))
return self
class MirrorStatusListV3(pydantic.BaseModel):
cutoff: int
last_check: datetime.datetime

View File

@ -15,6 +15,7 @@ from .exceptions import SysCallError, DownloadTimeout
from .output import error, info
from .pacman import Pacman
class DownloadTimer():
'''
Context manager for timing downloads with timeouts.
@ -150,6 +151,7 @@ def calc_checksum(icmp_packet) -> int:
return checksum
def build_icmp(payload: bytes) -> bytes:
# Define the ICMP Echo Request packet
icmp_packet = struct.pack('!BBHHH', 8, 0, 0, 0, 1) + payload
@ -158,6 +160,7 @@ def build_icmp(payload: bytes) -> bytes:
return struct.pack('!BBHHH', 8, 0, checksum, 0, 1) + payload
def ping(hostname, timeout=5) -> int:
watchdog = select.epoll()
started = time.time()

View File

@ -13,6 +13,7 @@ from .storage import storage
if TYPE_CHECKING:
from _typeshed import DataclassInstance
class FormattedOutput:
@classmethod
@ -330,10 +331,12 @@ def log(
sys.stdout.write(f"{text}\n")
sys.stdout.flush()
def _count_wchars(string: str) -> int:
"Count the total number of wide characters contained in a string"
return sum(unicodedata.east_asian_width(c) in 'FW' for c in string)
def unicode_ljust(string: str, width: int, fillbyte: str = ' ') -> str:
"""Return a left-justified unicode string of length width.
>>> unicode_ljust('Hello', 15, '*')
@ -347,6 +350,7 @@ def unicode_ljust(string: str, width: int, fillbyte: str = ' ') -> str:
"""
return string.ljust(width - _count_wchars(string), fillbyte)
def unicode_rjust(string: str, width: int, fillbyte: str = ' ') -> str:
"""Return a right-justified unicode string of length width.
>>> unicode_rjust('Hello', 15, '*')

View File

@ -1,5 +1,6 @@
from enum import Enum
class Repo(Enum):
Multilib = "multilib"
Testing = "testing"