From e8fc106776d066e4d8f36e6ea84e5cc98742abff Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Thu, 27 Jun 2024 21:14:56 +0800 Subject: feat(rules): add decorator: aliases for class attribute property --- hrc/rules/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hrc/rules/__init__.py b/hrc/rules/__init__.py index a32b693..ff1c230 100644 --- a/hrc/rules/__init__.py +++ b/hrc/rules/__init__.py @@ -1,3 +1,4 @@ +import functools from typing import Generic, Any, Type from abc import ABC @@ -8,5 +9,11 @@ from ..typing import RulesT class Rules(ABC, Generic[RulesT]): ... - - + + +def aliases(names, ignore_case=False): + def decorator(func): + func._aliases = names + func._ignore_case = ignore_case + return func + return decorator -- cgit v1.2.3-70-g09d2