Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jhonabreul
Copy link
Collaborator

@jhonabreul jhonabreul 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

@Copilot Copilot AI 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
File Description
src/runtime/Types/MetaType.cs Added nb_bool method that returns 1 for truthiness.
src/runtime/Properties/AssemblyInfo.cs Updated assembly version to 2.0.44.
src/runtime/Native/TypeOffset.cs Added nb_bool offset property.
src/runtime/Native/ITypeOffsets.cs Added nb_bool property in the interface.
src/embed_tests/ClassManagerTests.cs Added 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

@jhonabreul jhonabreul merged commit 68a2183 into QuantConnect:master May 2, 2025
0 of 21 checks passed
@jhonabreul jhonabreul deleted the bug-meta-type-truthiness branch May 2, 2025 13:07
Sign up for free to 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