Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python 3.12 Support, Drop Python 3.7 #253

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: 5yutan5/[email protected]
with:
python-version: '3.11'
python-version: '3.12'
poetry-install--only: dev
poetry-install--no-root: 'true'
poetry-virtualenvs-in-project: 'true'
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v3
- uses: 5yutan5/[email protected]
with:
python-version: '3.11'
python-version: '3.12'
poetry-install--only: main,test
poetry-virtualenvs-in-project: 'true'
- run: poetry run pip install PyQt6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: tlambert03/setup-qt-libs@v1
- uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"
- uses: snok/install-poetry@v1

- name: Get tag
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
fail-fast: false
matrix: # Test each python and Qt-lib only once on each os.
os: [ubuntu-latest, macOS-latest, windows-latest]
py: ['3.7', '3.8', '3.9', '3.10', '3.11']
py: ['3.8', '3.9', '3.10', '3.11', '3.12']
include:
- {py: '3.7', qt: PyQt5~=5.15.0}
- {py: '3.8', qt: PySide2~=5.15.0}
- {py: '3.9', qt: PyQt6}
- {py: '3.10', qt: PySide6-Essentials}
- {py: '3.11', qt: PyQt6}
- {py: '3.12', qt: PyQt6}
runs-on: ${{ matrix.os }}
name: pytest (${{ matrix.os }}, ${{ matrix.py }}, ${{ matrix.qt }})

Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- uses: actions/checkout@v3
- uses: 5yutan5/[email protected]
with:
python-version: '3.11'
python-version: '3.12'
poetry-install--only: github-actions,test,main

- run: >-
Expand All @@ -88,7 +88,7 @@ jobs:
- uses: actions/checkout@v3
- uses: 5yutan5/[email protected]
with:
python-version: '3.11'
python-version: '3.12'
poetry-install--only: main
additional-dependency-cache-key: PyInstaller
- run: poetry run pip install -U PyInstaller
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-icon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: 5yutan5/[email protected]
with:
python-version: '3.11'
python-version: '3.12'
poetry-install--only: main
- name: Download latest svg and update style
run: |
Expand Down
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
pass_filenames: false

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
Expand Down Expand Up @@ -46,10 +46,10 @@ repos:
args: ["--schemafile", "style/colors/themes/validate.json"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py37-plus]
args: [--py38-plus]

- repo: https://github.com/psf/black
rev: 22.10.0
Expand All @@ -68,7 +68,7 @@ repos:
- id: absolufy-imports

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.11.5
hooks:
- id: isort

Expand All @@ -89,6 +89,7 @@ repos:
- flake8-rst-docstrings
- flake8-pytest-style
- pep8-naming
args: ['--ignore=E231,W503']

- repo: https://github.com/asottile/yesqa
rev: v1.4.0
Expand Down
1,849 changes: 954 additions & 895 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "PyQtDarkTheme"
version = "2.1.0"
version = "2.2.0"
description = "Flat dark theme for PySide and PyQt."
authors = ["Yunosuke Ohsugi <[email protected]>"]
license = "MIT"
Expand All @@ -20,21 +20,21 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

[tool.poetry.dependencies]
python = ">=3.7,<3.12"
python = ">=3.8,<3.13"
darkdetect = "^0.7.1"

[tool.poetry.group.dev.dependencies]
black = "^22.10.0"
isort = "^5.10.1"
pre-commit = "^2.20.0"
pre-commit = "^3.5.0"

[tool.poetry.group.flake8.dependencies]
flake8 = "^5.0.4"
Expand Down
43 changes: 26 additions & 17 deletions qdarktheme/_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,35 @@ def a(self) -> float:


class _HSLA:
def __init__(self, h: int, s: float, l: float, a: float = 1) -> None: # noqa: E741
self._h = max(min(360, h), 0) | 0
self._s = _round_float(max(min(1, s), 0))
self._l = _round_float(max(min(1, l), 0))
self._a = _round_float(max(min(1, a), 0))
def __init__(self, hue: int, sat: float, lum: float, alpha: float = 1) -> None:
self._h = max(min(360, hue), 0) | 0
self._s = _round_float(max(min(1, sat), 0))
self._l = _round_float(max(min(1, lum), 0))
self._a = _round_float(max(min(1, alpha), 0))

def __eq__(self, other: _HSLA) -> bool:
"""Returns true if `h`, `s`, `l` and `a` are all the same."""
return [self.h, self.s, self.l, self.a] == [other.h, other.s, other.l, other.a]
"""Returns true if `hue`, `sat`, `lum` and `alpha` are all the same."""
return [self.hue, self.sat, self.lum, self.alpha] == [
other.hue,
other.sat,
other.lum,
other.alpha,
]

@property
def h(self) -> int:
def hue(self) -> int:
return self._h

@property
def s(self) -> float:
def sat(self) -> float:
return self._s

@property
def l(self) -> float: # noqa: E741, E743
def lum(self) -> float:
return self._l

@property
def a(self) -> float:
def alpha(self) -> float:
return self._a

@staticmethod
Expand All @@ -92,8 +97,8 @@ def from_rgba(rgba: _RGBA) -> _HSLA:
return _HSLA(int(hls[0] * 360), hls[2], hls[1], rgba.a)

def to_rgba(self) -> _RGBA:
rgb = colorsys.hls_to_rgb(self.h / 360, self.l, self.s)
return _RGBA(round(rgb[0] * 255), round(rgb[1] * 255), round(rgb[2] * 255), self.a)
rgb = colorsys.hls_to_rgb(self.hue / 360, self.lum, self.sat)
return _RGBA(round(rgb[0] * 255), round(rgb[1] * 255), round(rgb[2] * 255), self.alpha)


class Color:
Expand Down Expand Up @@ -187,7 +192,7 @@ def _to_hex(self) -> str:
r, g, b, a = self.rgba.r, self.rgba.g, self.rgba.b, self.rgba.a
hex_color = f"{math.floor(r):02x}{math.floor(g):02x}{math.floor(b):02x}"
if a != 1:
hex_color += f"{math.floor(a*255):02x}"
hex_color += f"{math.floor(a * 255):02x}"
return hex_color

def to_hex_argb(self) -> str:
Expand All @@ -200,7 +205,7 @@ def to_hex_argb(self) -> str:
str: Hex converted from Color object.
"""
r, g, b, a = self.rgba.r, self.rgba.g, self.rgba.b, self.rgba.a
hex_color = "" if a == 1 else f"{math.floor(a*255):02x}"
hex_color = "" if a == 1 else f"{math.floor(a * 255):02x}"
hex_color += f"{math.floor(r):02x}{math.floor(g):02x}{math.floor(b):02x}"
return hex_color

Expand All @@ -220,11 +225,15 @@ def to_svg_tiny_color_format(self) -> str:

def lighten(self, factor: float) -> Color:
"""Lighten color."""
return Color(_HSLA(self.hsla.h, self.hsla.s, self.hsla.l + self.hsla.l * factor, self.hsla.a))
return Color(
_HSLA(self.hsla.hue, self.hsla.sat, self.hsla.lum + self.hsla.lum * factor, self.hsla.alpha)
)

def darken(self, factor: float) -> Color:
"""Darken color."""
return Color(_HSLA(self.hsla.h, self.hsla.s, self.hsla.l - self.hsla.l * factor, self.hsla.a))
return Color(
_HSLA(self.hsla.hue, self.hsla.sat, self.hsla.lum - self.hsla.lum * factor, self.hsla.alpha)
)

def transparent(self, factor: float) -> Color:
"""Make color transparent."""
Expand Down
2 changes: 1 addition & 1 deletion qdarktheme/_icon/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from qdarktheme._color import Color


@lru_cache()
@lru_cache
def _svg_resources() -> dict[str, str]:
return json.loads(_resources.svg.SVG_RESOURCES)

Expand Down