Last active
July 31, 2023 17:13
Revisions
-
mnogom revised this gist
Jul 31, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,4 +10,4 @@ def __init_subclass__(cls, **kwargs): raise CellCantHasExtraFieldException( f"Нельзя расширять класс. Дополнительные поля: {extra_dir}" ) return super().__init_subclass__(**kwargs) -
mnogom created this gist
Jul 31, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ class Parent ... @classmethod def __init_subclass__(cls, **kwargs): dir_subclass = set(field for field in dir(cls) if not field.startswith(f"_{cls.__name__}__")) dir_base = set(field for field in dir(cls.__base__)) extra_dir = dir_subclass.difference(dir_base) if extra_dir: raise CellCantHasExtraFieldException( f"Нельзя расширять класс. Дополнительные поля: {extra_dir}" ) return super().__init_subclass__(**kwargs)