From 8d010e9c2dcfae7699eb9302df134ce4b54b95cc Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 11 Feb 2022 20:37:06 +0100 Subject: [PATCH] Turn TagWeight into a dataclass --- lektor_tags.py | 10 ++++++---- setup.cfg | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lektor_tags.py b/lektor_tags.py index 387f162..3f8b7ba 100644 --- a/lektor_tags.py +++ b/lektor_tags.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import collections import posixpath +from dataclasses import dataclass from math import log import pkg_resources @@ -67,11 +68,12 @@ def build_artifact(self, artifact): artifact.render_template_into(self.source.template_name, this=self.source) +@dataclass class TagWeight: - def __init__(self, count, mincount, maxcount): - self.count = count - self.mincount = mincount - self.maxcount = maxcount + + count: int + mincount: int + maxcount: int def __lt__(self, other): return self.count < other.count diff --git a/setup.cfg b/setup.cfg index eecdbb2..7f5220b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,6 +21,8 @@ include_package_data = True setup_requires = setuptools >= 45 setuptools_scm >= 6 +install_requires = + dataclasses;python_version<"3.7" [options.entry_points] lektor.plugins =