From ada2a976f003f505181d2f252ef907f8caa345e0 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 18 Nov 2022 13:25:12 -0800 Subject: mlog: use a hidden class for state This is a pretty common pattern in python (the standard library uses it a ton): A class is created, with a single private instance in the module, and then it's methods are exposed as public API. This removes the need for the global statement, and is generally a little easier to reason about thanks to encapsulation. --- docs/refman/generatorprint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/refman') diff --git a/docs/refman/generatorprint.py b/docs/refman/generatorprint.py index d836091cd..d80529603 100644 --- a/docs/refman/generatorprint.py +++ b/docs/refman/generatorprint.py @@ -19,7 +19,7 @@ from mesonbuild import mlog import typing as T def my_nested() -> T.ContextManager[None]: - prefix = '|' * len(mlog.log_depth) + prefix = '|' * mlog.get_log_depth() return mlog.nested(prefix) class GeneratorPrint(GeneratorBase): -- cgit v1.2.3