1111of dimensions referenced by variables.
1212
1313"""
14+
1415from functools import wraps
1516from typing import (
1617 Any ,
@@ -377,7 +378,7 @@ def _addlines_indent(text, indent=""):
377378
378379
379380# common indent spacing
380- _indent = " " * 4
381+ _STANDARD_INDENT = " " * 4
381382
382383
383384class NcData (_AttributeAccessMixin ):
@@ -420,7 +421,7 @@ def _print_content(self) -> str:
420421 class, so it isn't technically an abstract method).
421422 This "NcData._print_content()" is called recursively for groups.
422423 """
423- global _indent
424+ global _STANDARD_INDENT # noqa: F824
424425 # Define a header line (always a separate line).
425426 noname = "<'no-name'>"
426427 lines = [f"<NcData: { self .name or noname } " ]
@@ -431,20 +432,20 @@ def _print_content(self) -> str:
431432 if len (els ):
432433 if eltype == "attributes" :
433434 # Attributes a bit different: #1 add 'globol' to section title.
434- lines += [f"{ _indent } global attributes:" ]
435+ lines += [f"{ _STANDARD_INDENT } global attributes:" ]
435436 # NOTE: #2 show like variable attributes, but *no parent name*.
436437 attrs_lines = [
437438 f":{ attr ._print_content ()} "
438439 for attr in self .attributes .values ()
439440 ]
440441 lines += _addlines_indent (
441- "\n " .join (attrs_lines ), _indent * 2
442+ "\n " .join (attrs_lines ), _STANDARD_INDENT * 2
442443 )
443444 else :
444- lines += [f"{ _indent } { eltype } :" ]
445+ lines += [f"{ _STANDARD_INDENT } { eltype } :" ]
445446 for el in els .values ():
446447 lines += _addlines_indent (
447- el ._print_content (), _indent * 2
448+ el ._print_content (), _STANDARD_INDENT * 2
448449 )
449450 lines .append ("" )
450451
@@ -589,7 +590,7 @@ def __init__(
589590 # return self.data.shape
590591
591592 def _print_content (self ):
592- global _indent
593+ global _STANDARD_INDENT # noqa: F824
593594 dimstr = ", " .join (self .dimensions )
594595 typestr = str (self .dtype ) if self .dtype else "<no-dtype>"
595596 hdr = f"<NcVariable({ typestr } ): { self .name } ({ dimstr } )"
@@ -602,7 +603,7 @@ def _print_content(self):
602603 f"{ self .name } :{ attr ._print_content ()} "
603604 for attr in self .attributes .values ()
604605 ]
605- lines += _addlines_indent ("\n " .join (attrs_lines ), _indent )
606+ lines += _addlines_indent ("\n " .join (attrs_lines ), _STANDARD_INDENT )
606607 lines += [">" ]
607608 return "\n " .join (lines )
608609
0 commit comments