From a252b459a2eabaf21c9476cdafe81317c31cf267 Mon Sep 17 00:00:00 2001 From: Blender Defender Date: Thu, 25 Jul 2024 19:18:45 +0200 Subject: [PATCH] refactor: Update the type annotation in `ConvertLengthUnit.py` to be a literal --- .../ifcpatch/recipes/ConvertLengthUnit.py | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ifcpatch/ifcpatch/recipes/ConvertLengthUnit.py b/src/ifcpatch/ifcpatch/recipes/ConvertLengthUnit.py index dce1aaa60e..f9874656f7 100644 --- a/src/ifcpatch/ifcpatch/recipes/ConvertLengthUnit.py +++ b/src/ifcpatch/ifcpatch/recipes/ConvertLengthUnit.py @@ -24,6 +24,31 @@ import ifcopenshell.util.element import ifcopenshell.util.unit from logging import Logger +import typing + +LengthUnit = typing.Literal[ + "ATTOMETER", + "CENTIMETER", + "DECAMETER", + "DECIMETER", + "EXAMETER", + "FEMTOMETER", + "GIGAMETER", + "HECTOMETER", + "KILOMETER", + "MEGAMETER", + "METER", + "MICROMETER", + "MILLIMETER", + "NANOMETER", + "PETAMETER", + "PICOMETER", + "TERAMETER", + "INCH", + "FOOT", + "MILE", +] + class Patcher: def __init__( @@ -31,7 +56,7 @@ class Patcher: src: str, file: ifcopenshell.file, logger: Logger, - unit: str = "METER", + unit: LengthUnit = "METER", ): """Converts the length unit of a model to the specified unit