From 9cc6a1c8ceda9465a9c0a3529dfc67452e951fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Fri, 11 Dec 2020 11:53:36 +0100 Subject: [PATCH 1/3] Fix isort config --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 9dccd37..27e14fd 100644 --- a/tox.ini +++ b/tox.ini @@ -45,7 +45,7 @@ skip_install = true commands = python setup.py check --strict --metadata flake8 src tests setup.py - isort --check-only --diff --recursive --project czml3 --section-default THIRDPARTY src tests + isort --check-only --diff --project czml3 --section-default THIRDPARTY src tests black --check src tests --exclude=_version.py mypy --ignore-missing-imports --check-untyped-defs --no-strict-optional src tests @@ -56,5 +56,5 @@ deps = isort skip_install = true commands = - isort --recursive --project czml3 --section-default THIRDPARTY src tests setup.py + isort --project czml3 --section-default THIRDPARTY src tests setup.py black src tests setup.py --exclude=_version.py From 923858390546b47ad4e522c18ad89d5205bceba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Fri, 11 Dec 2020 11:55:13 +0100 Subject: [PATCH 2/3] Quality --- setup.py | 3 ++- src/czml3/properties.py | 26 +++++++++++++++++++------- src/czml3/types.py | 4 ++-- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 6318d92..dc7db17 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ -import versioneer from setuptools import setup +import versioneer + setup(version=versioneer.get_version(), cmdclass=versioneer.get_cmdclass()) diff --git a/src/czml3/properties.py b/src/czml3/properties.py index 946ac68..b40b404 100644 --- a/src/czml3/properties.py +++ b/src/czml3/properties.py @@ -207,7 +207,7 @@ class Position(BaseCZMLObject, Interpolatable, Deletable): cartesianVelocity = attr.ib(default=None) reference = attr.ib(default=None) - def __attrs_post_init__(self,): + def __attrs_post_init__(self): if all( val is None for val in ( @@ -233,8 +233,14 @@ class ViewFrom(BaseCZMLObject, Interpolatable, Deletable): cartesian = attr.ib(default=None) reference = attr.ib(default=None) - def __attrs_post_init__(self,): - if all(val is None for val in (self.cartesian, self.reference,)): + def __attrs_post_init__(self): + if all( + val is None + for val in ( + self.cartesian, + self.reference, + ) + ): raise ValueError("One of cartesian or reference must be given") @@ -471,8 +477,14 @@ class RectangleCoordinates(BaseCZMLObject, Interpolatable, Deletable): wsen = attr.ib(default=None) wsenDegrees = attr.ib(default=None) - def __attrs_post_init__(self,): - if all(val is None for val in (self.wsen, self.wsenDegrees,)): + def __attrs_post_init__(self): + if all( + val is None + for val in ( + self.wsen, + self.wsenDegrees, + ) + ): raise ValueError( "One of cartesian, cartographicDegrees or cartographicRadians must be given" ) @@ -565,7 +577,7 @@ class TileSet(BaseCZMLObject): @attr.s(repr=False, frozen=True, kw_only=True) class Wall(BaseCZMLObject): """A two-dimensional wall defined as a line strip and optional maximum and minimum heights. - It conforms to the curvature of the globe and can be placed along the surface or at altitude.""" + It conforms to the curvature of the globe and can be placed along the surface or at altitude.""" show = attr.ib(default=None) positions = attr.ib() @@ -583,7 +595,7 @@ class Wall(BaseCZMLObject): @attr.s(repr=False, frozen=True, kw_only=True) class NearFarScalar(BaseCZMLObject, Interpolatable, Deletable): - """ A numeric value which will be linearly interpolated between two values based on an object's distance from the + """A numeric value which will be linearly interpolated between two values based on an object's distance from the camera, in eye coordinates. The computed value will interpolate between the near value and the far value while the camera distance falls diff --git a/src/czml3/types.py b/src/czml3/types.py index d7a8a22..88b6117 100644 --- a/src/czml3/types.py +++ b/src/czml3/types.py @@ -137,7 +137,7 @@ def to_json(self): @attr.s(repr=False, frozen=True, kw_only=True) class ReferenceValue(BaseCZMLObject): - """ Represents a reference to another property. References can be used to specify that two properties on different + """Represents a reference to another property. References can be used to specify that two properties on different objects are in fact, the same property. """ @@ -217,7 +217,7 @@ def to_json(self): @attr.s(repr=False, frozen=True, kw_only=True) class CartographicRadiansListValue(BaseCZMLObject): """A list of geodetic, WGS84 positions specified as [Longitude, Latitude, Height, Longitude, Latitude, Height, ...], - where Longitude and Latitude are in radians and Height is in meters.""" + where Longitude and Latitude are in radians and Height is in meters.""" values = attr.ib() From 318a1cba54cbe1b5f52b5a80ad9847f5876b1eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Fri, 11 Dec 2020 13:06:20 +0100 Subject: [PATCH 3/3] WIP: Adapt typing Non-systematic approach, only made tests pass. Added numerous TODOs for future reference. --- mypy.ini | 22 +++++ src/czml3/base.py | 2 +- src/czml3/common.py | 19 ++-- src/czml3/properties.py | 201 +++++++++++++++++++++++---------------- src/czml3/types.py | 9 +- src/czml3/utils.py | 2 +- tests/test_properties.py | 2 +- tests/test_types.py | 2 +- 8 files changed, 161 insertions(+), 98 deletions(-) diff --git a/mypy.ini b/mypy.ini index fa80069..074fd60 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,4 +1,26 @@ [mypy] +files = + src/**/*.py, + tests/**/*.py +warn_redundant_casts = True +warn_unused_configs = True +pretty = True +show_error_codes = True + +disallow_any_generics = True +disallow_subclassing_any = True +# disallow_untyped_calls = True +disallow_incomplete_defs = True +# check_untyped_defs = True +disallow_untyped_decorators = True +no_implicit_optional = True +warn_unused_ignores = True +warn_return_any = True +no_implicit_reexport = True + +# More strict checks for library code +[mypy-czml3] +disallow_untyped_defs = True [mypy-versioneer] ignore_errors = True diff --git a/src/czml3/base.py b/src/czml3/base.py index 567177f..91fc75b 100644 --- a/src/czml3/base.py +++ b/src/czml3/base.py @@ -25,7 +25,7 @@ def default(self, o): return super().default(o) -@attr.s(repr=False, frozen=True) +@attr.s(auto_attribs=True, repr=False, frozen=True) class BaseCZMLObject: def __repr__(self): return self.dumps(indent=4) diff --git a/src/czml3/common.py b/src/czml3/common.py index e5df9a8..2f308ac 100644 --- a/src/czml3/common.py +++ b/src/czml3/common.py @@ -1,35 +1,36 @@ # noinspection PyPep8Naming import datetime as dt +from typing import Optional import attr from .enums import HorizontalOrigins, InterpolationAlgorithms, VerticalOrigins -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class Deletable: """A property whose value may be deleted.""" - delete: bool = attr.ib(default=None) + delete: Optional[bool] = None # noinspection PyPep8Naming -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class Interpolatable: """A property whose value may be determined by interpolating. The interpolation happens over provided time-tagged samples. """ - epoch: dt.datetime = attr.ib(default=None) - interpolationAlgorithm: InterpolationAlgorithms = attr.ib(default=None) - interpolationDegree: int = attr.ib(default=None) + epoch: Optional[dt.datetime] = None + interpolationAlgorithm: Optional[InterpolationAlgorithms] = None + interpolationDegree: Optional[int] = None # noinspection PyPep8Naming -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class HasAlignment: """A property that can be horizontally or vertically aligned.""" - horizontalOrigin: HorizontalOrigins = attr.ib(default=None) - verticalOrigin: VerticalOrigins = attr.ib(default=None) + horizontalOrigin: Optional[HorizontalOrigins] = None + verticalOrigin: Optional[VerticalOrigins] = None diff --git a/src/czml3/properties.py b/src/czml3/properties.py index b40b404..a4bd75f 100644 --- a/src/czml3/properties.py +++ b/src/czml3/properties.py @@ -1,10 +1,33 @@ +from typing import Any, List, Optional, Union + import attr from w3lib.url import is_url, parse_data_uri from .base import BaseCZMLObject from .common import Deletable, HasAlignment, Interpolatable -from .enums import ClockRanges, ClockSteps, LabelStyles, StripeOrientations -from .types import RgbafValue, RgbaValue +from .enums import ( + ArcTypes, + ClassificationTypes, + ClockRanges, + ClockSteps, + LabelStyles, + ReferenceFrames, + ShadowModes, + StripeOrientations, +) +from .types import ( + Cartesian3Value, + CartographicDegreesListValue, + CartographicDegreesValue, + CartographicRadiansListValue, + CartographicRadiansValue, + DistanceDisplayConditionValue, + NearFarScalarValue, + ReferenceValue, + RgbafValue, + RgbaValue, + UnitQuaternionValue, +) @attr.s(repr=False, frozen=True, kw_only=True) @@ -118,12 +141,12 @@ class ImageMaterial(BaseCZMLObject): transparent = attr.ib(default=False) -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class Color(BaseCZMLObject, Interpolatable, Deletable): """A color. The color can optionally vary over time.""" - rgba = attr.ib(default=None) - rgbaf = attr.ib(default=None) + rgba: Optional[Union[RgbaValue, List[int]]] = None # TODO: Add classmethod? + rgbaf: Optional[RgbafValue] = None @classmethod def is_valid(cls, color): @@ -196,16 +219,20 @@ def from_str(cls, color): # noinspection PyPep8Naming -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class Position(BaseCZMLObject, Interpolatable, Deletable): """Defines a position. The position can optionally vary over time.""" - referenceFrame = attr.ib(default=None) - cartesian = attr.ib(default=None) - cartographicRadians = attr.ib(default=None) - cartographicDegrees = attr.ib(default=None) - cartesianVelocity = attr.ib(default=None) - reference = attr.ib(default=None) + referenceFrame: Optional[ReferenceFrames] = None + cartesian: Optional[ + Union[Cartesian3Value, List[float]] + ] = None # TODO: Add classmethod? + cartographicRadians: Optional[CartographicRadiansValue] = None + cartographicDegrees: Optional[ + Union[CartographicDegreesValue, List[float]] + ] = None # TODO: Add classmethod? + cartesianVelocity: Optional[Any] = None # TODO: Implement class + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? def __attrs_post_init__(self): if all( @@ -224,14 +251,16 @@ def __attrs_post_init__(self): # noinspection PyPep8Naming -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class ViewFrom(BaseCZMLObject, Interpolatable, Deletable): """suggested initial camera position offset when tracking this object. ViewFrom can optionally vary over time.""" - cartesian = attr.ib(default=None) - reference = attr.ib(default=None) + cartesian: Optional[ + Union[Cartesian3Value, List[float]] + ] = None # TODO: Add classmethod? + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? def __attrs_post_init__(self): if all( @@ -245,7 +274,7 @@ def __attrs_post_init__(self): # noinspection PyPep8Naming -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class Billboard(BaseCZMLObject, HasAlignment): """A billboard, or viewport-aligned image. @@ -253,18 +282,20 @@ class Billboard(BaseCZMLObject, HasAlignment): A billboard is sometimes called a marker. """ - image = attr.ib() - show = attr.ib(default=None) - scale = attr.ib(default=None) - eyeOffset = attr.ib(default=None) + image: Union["Uri", str] # TODO: Add classmethod? + show: Optional[bool] = None + scale: Optional[float] = None + eyeOffset: Optional["EyeOffset"] = None -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class EllipsoidRadii(BaseCZMLObject, Interpolatable, Deletable): """The radii of an ellipsoid.""" - cartesian = attr.ib(default=None) - reference = attr.ib(default=None) + cartesian: Optional[ + Union[Cartesian3Value, List[float]] + ] = None # TODO: Add classmethod? + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? @attr.s(repr=False, frozen=True, kw_only=True) @@ -276,9 +307,13 @@ class Corridor(BaseCZMLObject): show = attr.ib(default=None) width = attr.ib() height = attr.ib(default=None) - heightReference = attr.ib(default=None) + heightreference: Optional[ + Union[ReferenceValue, str] + ] = None # TODO: Add classmethod? extrudedHeight = attr.ib(default=None) - extrudedHeightReference = attr.ib(default=None) + extrudedHeightreference: Optional[ + Union[ReferenceValue, str] + ] = None # TODO: Add classmethod? cornerType = attr.ib(default=None) granularity = attr.ib(default=None) fill = attr.ib(default=None) @@ -372,47 +407,51 @@ class Polyline(BaseCZMLObject): zIndex = attr.ib(default=None) -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class ArcType(BaseCZMLObject, Deletable): """The type of an arc.""" - arcType = attr.ib(default=None) - reference = attr.ib(default=None) + arcType: Optional[ArcTypes] = None + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class ShadowMode(BaseCZMLObject, Deletable): """Whether or not an object casts or receives shadows from each light source when shadows are enabled.""" - shadowMode = attr.ib(default=None) - referenec = attr.ib(default=None) + shadowMode: Optional[ShadowModes] = attr.ib(default=None) + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class ClassificationType(BaseCZMLObject, Deletable): """Whether a classification affects terrain, 3D Tiles, or both.""" - classificationType = attr.ib(default=None) - reference = attr.ib(default=None) + classificationType: Optional[ClassificationTypes] = None + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class DistanceDisplayCondition(BaseCZMLObject, Interpolatable, Deletable): """Indicates the visibility of an object based on the distance to the camera.""" - distanceDisplayCondition = attr.ib(default=None) - reference = attr.ib(default=None) + distanceDisplayCondition: Optional[DistanceDisplayConditionValue] = None + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class PositionList(BaseCZMLObject, Deletable): """A list of positions.""" - referenceFrame = attr.ib(default=None) - cartesian = attr.ib(default=None) - cartographicRadians = attr.ib(default=None) - cartographicDegrees = attr.ib(default=None) - references = attr.ib(default=None) + referenceFrame: Optional[ReferenceFrames] = None + cartesian: Optional[Any] = None # TODO: Implement class + cartographicRadians: Optional[ + Union[CartographicRadiansListValue, List[float]] + ] = None # TODO: Add classmethod? + cartographicDegrees: Optional[ + Union[CartographicDegreesListValue, List[float]] + ] = None # TODO: Add classmethod? + references: Optional[Any] = None # TODO: Implement class @attr.s(repr=False, frozen=True, kw_only=True) @@ -448,34 +487,34 @@ class Box(BaseCZMLObject): distanceDisplayCondition = attr.ib(default=None) -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class BoxDimensions(BaseCZMLObject, Interpolatable): """The width, depth, and height of a box.""" - cartesian = attr.ib(default=None) - reference = attr.ib(default=None) + cartesian: Optional[Cartesian3Value] = None + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? # noinspection PyPep8Naming -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class Rectangle(BaseCZMLObject, Interpolatable, Deletable): """A cartographic rectangle, which conforms to the curvature of the globe and can be placed on the surface or at altitude and can optionally be extruded into a volume.""" - coordinates = attr.ib(default=None) - fill = attr.ib(default=None) - material = attr.ib(default=None) + coordinates: Optional["RectangleCoordinates"] = None + fill: Optional[bool] = True + material: Optional[Material] = None # noinspection PyPep8Naming -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class RectangleCoordinates(BaseCZMLObject, Interpolatable, Deletable): """A set of coordinates describing a cartographic rectangle on the surface of the ellipsoid.""" - reference = attr.ib(default=None) - wsen = attr.ib(default=None) - wsenDegrees = attr.ib(default=None) + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? + wsen: Optional[Any] = None # TODO: Implement class + wsenDegrees: Optional[Any] = None # TODO: Implement class def __attrs_post_init__(self): if all( @@ -490,7 +529,7 @@ def __attrs_post_init__(self): ) -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class EyeOffset(BaseCZMLObject, Deletable): """An offset in eye coordinates which can optionally vary over time. @@ -500,16 +539,16 @@ class EyeOffset(BaseCZMLObject, Deletable): """ - cartesian = attr.ib(default=None) - reference = attr.ib(default=None) + cartesian: Optional[Cartesian3Value] = None + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class HeightReference(BaseCZMLObject, Deletable): """The height reference of an object, which indicates if the object's position is relative to terrain or not.""" - heightReference = attr.ib(default=None) - reference = attr.ib(default=None) + heightReference: Optional[Any] = None # TODO: Implement class + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? # noinspection PyPep8Naming @@ -593,7 +632,7 @@ class Wall(BaseCZMLObject): distanceDisplayCondition = attr.ib(default=None) -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class NearFarScalar(BaseCZMLObject, Interpolatable, Deletable): """A numeric value which will be linearly interpolated between two values based on an object's distance from the camera, in eye coordinates. @@ -603,29 +642,29 @@ class NearFarScalar(BaseCZMLObject, Interpolatable, Deletable): less than the near distance or greater than the far distance, respectively. """ - nearFarScalar = attr.ib(default=None) - reference = attr.ib(default=None) + nearFarScalar: Optional[NearFarScalarValue] = None + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? # noinspection PyPep8Naming -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class Label(BaseCZMLObject, HasAlignment): """A string of text.""" - show = attr.ib(default=True) - text = attr.ib(default=None) - font = attr.ib(default=None) - style = attr.ib(default=LabelStyles.FILL) - scale = attr.ib(default=None) - showBackground = attr.ib(default=None) - backgroundColor = attr.ib(default=None) - fillColor = attr.ib(default=None) - outlineColor = attr.ib(default=None) - outlineWidth = attr.ib(default=1.0) - pixelOffset = attr.ib(default=None) + show: bool = True + text: Optional[str] = None + font: Optional[str] = None + style: LabelStyles = LabelStyles.FILL + scale: Optional[float] = None + showBackground: Optional[bool] = None + backgroundColor: Optional[Color] = None + fillColor: Optional[Color] = None + outlineColor: Optional[Color] = None + outlineWidth: float = 1.0 + pixelOffset: Optional[Any] = None # TODO: Implement class -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class Orientation(BaseCZMLObject, Interpolatable, Deletable): """Defines an orientation. @@ -634,9 +673,9 @@ class Orientation(BaseCZMLObject, Interpolatable, Deletable): """ - unitQuaternion = attr.ib(default=None) - reference = attr.ib(default=None) - velocityReference = attr.ib(default=None) + unitQuaternion: Optional[UnitQuaternionValue] = None + reference: Optional[Union[ReferenceValue, str]] = None # TODO: Add classmethod? + velocityReference: Optional[Any] = None # TODO: Implement class @attr.s(repr=False, frozen=True, kw_only=True) @@ -662,14 +701,14 @@ class Model(BaseCZMLObject): articulations = attr.ib(default=None) -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class Uri(BaseCZMLObject, Deletable): """A URI value. The URI can optionally vary with time. """ - uri = attr.ib(default=None) + uri: Optional[str] = None @uri.validator def _check_uri(self, attribute, value): diff --git a/src/czml3/types.py b/src/czml3/types.py index 88b6117..e519fe8 100644 --- a/src/czml3/types.py +++ b/src/czml3/types.py @@ -1,4 +1,5 @@ import datetime as dt +from typing import List, Union import attr from dateutil.parser import isoparse as parse_iso_date @@ -61,7 +62,7 @@ def to_json(self): return self.font -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class RgbafValue(BaseCZMLObject): """A color specified as an array of color components [Red, Green, Blue, Alpha] where each component is in the range 0.0-1.0. If the array has four elements, @@ -71,7 +72,7 @@ class RgbafValue(BaseCZMLObject): """ - values = attr.ib() + values: List[Union[str, float]] = attr.ib() @values.validator def _check_values(self, attribute, value): @@ -96,7 +97,7 @@ def to_json(self): return list(self.values) -@attr.s(repr=False, frozen=True, kw_only=True) +@attr.s(auto_attribs=True, repr=False, frozen=True, kw_only=True) class RgbaValue(BaseCZMLObject): """A color specified as an array of color components [Red, Green, Blue, Alpha] where each component is in the range 0-255. If the array has four elements, @@ -108,7 +109,7 @@ class RgbaValue(BaseCZMLObject): """ - values = attr.ib() + values: List[Union[str, int]] = attr.ib() @values.validator def _check_values(self, attribute, value): diff --git a/src/czml3/utils.py b/src/czml3/utils.py index 6c7a239..3f289b6 100644 --- a/src/czml3/utils.py +++ b/src/czml3/utils.py @@ -27,7 +27,7 @@ def get_color_list(timestamps, colors, rgbaf=False): color_r = ( lambda c: c.rgbaf.values if c.rgbaf - else list(map(lambda x: x / 255, c.rgba.values)) + else list(map(lambda x: float(x / 255), c.rgba.values)) ) else: color_r = ( diff --git a/tests/test_properties.py b/tests/test_properties.py index eb072d1..5f73a8d 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -145,7 +145,7 @@ def test_polyline(): positions=PositionList( cartographicDegrees=CartographicDegreesListValue(values=[20, 30, 10]) ), - arcType=ArcType(arcType="GEODESIC"), + arcType=ArcType(arcType=ArcTypes.GEODESIC), distanceDisplayCondition=DistanceDisplayCondition( distanceDisplayCondition=DistanceDisplayConditionValue(values=[14, 81]) ), diff --git a/tests/test_types.py b/tests/test_types.py index 21ab2cc..7bbddfe 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -141,7 +141,7 @@ def test_bad_rgba_4_values_raises_error(): def test_bad_rgba_5_color_values_raises_error(): with pytest.raises(ValueError) as excinfo: - RgbaValue(values=[0, 0.1, 0.3, 0.3, 255]) + RgbaValue(values=[0, 0.1, 0.3, 0.3, 255]) # type: ignore assert "Color values must be integers in the range 0-255." in excinfo.exconly()