Skip to content

Commit

Permalink
Typing enables code completion for Cube.attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pp-mo committed Jul 30, 2023
1 parent 83eee13 commit ce5cdef
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/iris/cube.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright Iris contributors
# Copyright Iris contributors
#
# This file is part of Iris and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
Expand Down Expand Up @@ -930,19 +930,19 @@ def _normalise_attrs(
return attributes

@property
def locals(self):
def locals(self) -> LimitedAttributeDict:
return self._locals

@locals.setter
def locals(self, attributes):
def locals(self, attributes: Optional[Mapping]):
self._locals = self._normalise_attrs(attributes)

@property
def globals(self):
def globals(self) -> LimitedAttributeDict:
return self._globals

@globals.setter
def globals(self, attributes):
def globals(self, attributes: Optional[Mapping]):
self._globals = self._normalise_attrs(attributes)

#
Expand Down Expand Up @@ -1335,8 +1335,12 @@ def _names(self):
#
# Ensure that .attributes is always a :class:`CubeAttrsDict`.
#
@CFVariableMixin.attributes.setter
def attributes(self, attributes):
@property
def attributes(self) -> CubeAttrsDict:
return super().attributes

@attributes.setter
def attributes(self, attributes: Optional[Mapping]):
"""
An override to CfVariableMixin.attributes.setter, which ensures that Cube
attributes are stored in a way which distinguishes global + local ones.
Expand Down

0 comments on commit ce5cdef

Please sign in to comment.