Treat empty/non-str library overrides as unset - #60
Pitchfork-and-Torch wants to merge 1 commit into
Conversation
thread_local.name / current_async_library_cvar previously returned any non-None value, so "" or an int leaked as a false library name. Only accept non-empty str overrides; otherwise keep sniffing.
|
For type checking, there are already type hints. In this regard, runtime checks are redundant. As for empty strings, that makes even less sense. Your PR treats them as equivalent to |
|
I think setting this to an empty string is just like, sure whatever? Why should we assume that library code that integrates with sniffio, which is probably like 2 lines in a heavily tested async framework, can mess up this badly? |
Summary
Only treat non-empty
strvalues fromthread_local.name/current_async_library_cvaras library overrides.Previously any non-
Nonevalue was returned, so""or anintleaked as a false library name. Invalid overrides are ignored and sniffing continues.Test plan
sniffio/_tests/test_sniffio.py(incl.test_empty_name_ignored) passes