ソースを参照

[F] Fix #35 python 3.11 compatibility

Azalea (on HyDEV-Daisy) 2 年 前
コミット
e8c7266671
3 ファイル変更5 行追加7 行削除
  1. 1 1
      hyfetch/main.py
  2. 2 4
      hyfetch/models.py
  3. 2 2
      setup.py

+ 1 - 1
hyfetch/main.py

@@ -295,7 +295,7 @@ def create_config() -> Config:
         if random_count > len(perm):
             choices = perm
         else:
-            choices = random.sample(perm, random_count)
+            choices = random.sample(sorted(perm), random_count)
         choices = [{slots[i]: n for i, n in enumerate(c)} for c in choices]
         arrangements += [(f'random{i}', ColorAlignment('custom', r)) for i, r in enumerate(choices)]
         asciis = [[*ca.recolor_ascii(asc, _prs).split('\n'), k.center(asc_width)] for k, ca in arrangements]

+ 2 - 4
hyfetch/models.py

@@ -1,8 +1,6 @@
 from __future__ import annotations
 
-from dataclasses import dataclass
-
-from typing_extensions import Literal
+from dataclasses import dataclass, field
 
 from .color_util import AnsiMode, LightDark
 from .constants import CONFIG_PATH
@@ -16,7 +14,7 @@ class Config:
     mode: AnsiMode
     light_dark: LightDark = 'dark'
     lightness: float | None = None
-    color_align: ColorAlignment = ColorAlignment('horizontal')
+    color_align: ColorAlignment = field(default_factory=lambda: ColorAlignment('horizontal'))
 
     @classmethod
     def from_dict(cls, d: dict):

+ 2 - 2
setup.py

@@ -3,7 +3,7 @@ import pathlib
 
 from setuptools import setup
 
-import hyfetch
+import hyfetch.constants
 
 # The directory containing this file
 HERE = pathlib.Path(__file__).parent
@@ -14,7 +14,7 @@ README = (HERE / "README.md").read_text('utf-8')
 # This call to setup() does all the work
 setup(
     name="HyFetch",
-    version=hyfetch.__version__,
+    version=hyfetch.constants.VERSION,
     description="neofetch with flags <3",
     long_description=README,
     long_description_content_type="text/markdown",