Skip to content

Improves Null Key Handling in Python#9368

Open
AlexCatarino wants to merge 1 commit intoQuantConnect:masterfrom
AlexCatarino:feature-extended-dictionaty-null-keys
Open

Improves Null Key Handling in Python#9368
AlexCatarino wants to merge 1 commit intoQuantConnect:masterfrom
AlexCatarino:feature-extended-dictionaty-null-keys

Conversation

@AlexCatarino
Copy link
Copy Markdown
Member

Description

We aim to mimic the following behavior:

>>> d = {1:2}
>>> None in d
False
>>> d.get(None) is None
True
>>> d.pop(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: None
>>> d.pop(None, None) is None
True

Related Issue

N/A

Motivation and Context

The data dictionaries weren't behaving as we would expect in Python, forcing users to add unnecessary null checks.

Requires Documentation Change

No

How Has This Been Tested?

New unit tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

We aim to mimic the following behavior:

```python
>>> d = {1:2}
>>> None in d
False
>>> d.get(None) is None
True
>>> d.pop(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: None
>>> d.pop(None, None) is None
True
```
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.

1 participant