Skip to content

Treat an empty NoWarn element as no extra warning codes - #779

Merged
quantconnect-kronos[bot] merged 1 commit into
masterfrom
kronos/bug-746-empty-nowarn-csharp-setup
Nov 23, 2026
Merged

quantconnect-kronos[bot] merged 1 commit into
masterfrom
kronos/bug-746-empty-nowarn-csharp-setup

Conversation

@quantconnect-kronos

Copy link
Copy Markdown
Contributor

Closes #746

What changed and why

When a C# project's .csproj holds an empty NoWarn element (<NoWarn /> or <NoWarn></NoWarn>), lean backtest stopped before the build with Error: expected string or bytes-like object, got 'NoneType': the element's text is None and went straight to re.split. LeanRunner now reads an empty element as no extra codes, so the build gets only the default MSB3277. 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

  • New test_run_lean_inherits_no_warn_codes_from_csharp_project in tests/components/docker/test_lean_runner.py checks the build's NoWarn property 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 with TypeError: expected string or bytes-like object, got 'NoneType'.
  • Full suite: python -m pytest → 2912 passed, 81 skipped.
  • Tested end to end: a C# project created with lean create-project -l csharp whose NoWarn was 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 with Error: expected string or bytes-like object, got 'NoneType'.

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>
@quantconnect-kronos quantconnect-kronos Bot added kronos:develop:working develop: in progress kronos:review Request review labels Nov 23, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued kronos:review:working review: in progress and removed kronos:review Request review kronos:review:queued review: queued labels Nov 23, 2026
@quantconnect-kronos-reviewer
quantconnect-kronos-reviewer Bot marked this pull request as ready for review November 23, 2026 15:27

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added risk:low Low risk and removed kronos:review:working review: in progress labels Nov 23, 2026
@quantconnect-kronos quantconnect-kronos Bot added the kronos:review Request review label Nov 23, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued and removed kronos:review Request review labels Nov 23, 2026
@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot added kronos:review:working review: in progress and removed kronos:review:queued review: queued labels Nov 23, 2026

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot removed the kronos:review:working review: in progress label Nov 23, 2026
@quantconnect-kronos
quantconnect-kronos Bot merged commit ad1f9cb into master Nov 23, 2026
60 checks passed
@quantconnect-kronos
quantconnect-kronos Bot deleted the kronos/bug-746-empty-nowarn-csharp-setup branch November 23, 2026 15:43
@quantconnect-kronos quantconnect-kronos Bot removed the kronos:develop:working develop: in progress label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Low risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An empty NoWarn element prevents C# project setup

0 participants