comparison roundup/logcontext.py @ 8564:13732c1d8392

bug: fix typing for pre 3.9 python. when I added basic typing to logcontext.py I used a spec unsupported in 3.8and earlier.
author John Rouillard <rouilj@ieee.org>
date Thu, 09 Apr 2026 00:09:29 -0400
parents f80c566f5726
children
comparison
equal deleted inserted replaced
8563:909cf30c01c1 8564:13732c1d8392
36 import contextvars 36 import contextvars
37 import functools 37 import functools
38 import logging 38 import logging
39 import os 39 import os
40 import uuid 40 import uuid
41 from typing import Callable 41 from typing import Callable, Dict
42 42
43 43
44 def short_uuid() -> str: 44 def short_uuid() -> str:
45 """Encode a UUID integer in a shorter form for display. 45 """Encode a UUID integer in a shorter form for display.
46 46
113 113
114 # store the context variable names in a dict. Because 114 # store the context variable names in a dict. Because
115 # contactvars.copy_context().items() returns nothing if set has 115 # contactvars.copy_context().items() returns nothing if set has
116 # not been called on a context var. I need the contextvar names 116 # not been called on a context var. I need the contextvar names
117 # even if they have not been set. 117 # even if they have not been set.
118 ctx_vars: dict[str, contextvars.ContextVar] = {} 118 ctx_vars: Dict[str, contextvars.ContextVar] = {}
119 119
120 # set up sentinel values that will print a suitable error value 120 # set up sentinel values that will print a suitable error value
121 # and the context vars they are associated with. 121 # and the context vars they are associated with.
122 _SENTINEL_PROCESSNAME = SimpleSentinel("processName", None) 122 _SENTINEL_PROCESSNAME = SimpleSentinel("processName", None)
123 ctx_vars['processName'] = contextvars.ContextVar("processName", 123 ctx_vars['processName'] = contextvars.ContextVar("processName",

Roundup Issue Tracker: http://roundup-tracker.org/