Repository navigation
Treat an empty NoWarn element as no extra warning codes - #779
Conversation
A C# project with `<NoWarn />` or `<NoWarn></NoWarn>` failed before its build with "expected string or bytes-like object, got 'NoneType'", because the element's text is None. Such an element now adds no codes, and a populated one keeps adding its codes as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approved. An empty <NoWarn /> / <NoWarn></NoWarn> now adds no codes, and a populated element still adds its codes as before, which is what #746 asks for. The or "" also covers whitespace-only text, since empty split parts are filtered out. I ran the new test against the base branch's lean_runner.py: both empty cases fail with the NoneType error, and all three pass with the fix.
I set risk:low: it's a one-expression fix with no effect on populated elements, the new test fails without it, CI is green, and the description reports an end-to-end run.
There was a problem hiding this comment.
Approved. Independently tested end to end: a C# project with <NoWarn /> builds with zero errors and completes its backtest; released CLI 1.0.234 fails on the same project with the reported NoneType error. Both empty-form regression cases fail on the base implementation and pass with this fix. Full suite: 2,912 passed, 81 skipped.
Closes #746
What changed and why
When a C# project's
.csprojholds an emptyNoWarnelement (<NoWarn />or<NoWarn></NoWarn>),lean backteststopped before the build withError: expected string or bytes-like object, got 'NoneType': the element's text isNoneand went straight tore.split.LeanRunnernow reads an empty element as no extra codes, so the build gets only the defaultMSB3277. A populated element adds its codes exactly as before.The change is one expression in
lean/components/docker/lean_runner.py; it is backwards compatible.Testing
test_run_lean_inherits_no_warn_codes_from_csharp_projectintests/components/docker/test_lean_runner.pychecks the build'sNoWarnproperty for<NoWarn />and<NoWarn></NoWarn>(NoWarn=MSB3277) and for<NoWarn>CS0618;CS1998</NoWarn>(NoWarn=MSB3277%3BCS0618%3BCS1998). Without the fix, the two empty cases fail withTypeError: expected string or bytes-like object, got 'NoneType'.python -m pytest→2912 passed, 81 skipped.lean create-project -l csharpwhoseNoWarnwas replaced by<NoWarn />builds (Build succeeded.,0 Error(s)) and its backtest completes with this branch. The released 1.0.234 stops on the same project withError: expected string or bytes-like object, got 'NoneType'.