Skip to content

Conversation

@jhonabreul
Copy link
Collaborator

@jhonabreuljhonabreul commented May 1, 2025

Add __bool__ for MetaType.

This is required so that truthiness for Type is checked using this slot instead of __len__

Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds an implementation for bool on the MetaType so that truthiness for types is evaluated using nb_bool rather than len.

  • Added nb_bool implementation in MetaType.cs that always returns 1.
  • Updated native type offsets (TypeOffset.cs and ITypeOffsets.cs) to include nb_bool.
  • Introduced embed_tests to verify that types are truthy in Python.

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
src/runtime/Types/MetaType.csAdded nb_bool method that returns 1 for truthiness.
src/runtime/Properties/AssemblyInfo.csUpdated assembly version to 2.0.44.
src/runtime/Native/TypeOffset.csAdded nb_bool offset property.
src/runtime/Native/ITypeOffsets.csAdded nb_bool property in the interface.
src/embed_tests/ClassManagerTests.csAdded tests to verify that types are always truthy.
Files not reviewed (2)
  • src/perf_tests/Python.PerformanceTests.csproj: Language not supported
  • src/runtime/Python.Runtime.csproj: Language not supported

@jhonabreuljhonabreul merged commit 68a2183 into QuantConnect:masterMay 2, 2025
0 of 21 checks passed
@jhonabreuljhonabreul deleted the bug-meta-type-truthiness branch May 2, 2025 13:07
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jhonabreul@Martin-Molinero