cognitedata / cognitedata/cognite-sdk-python

Subclasses of dict (like `Label`) do not work with `camel_case=False`

Open
#1,087 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
92
Forks
38
Avg merge
2d 9h
Merged PRs (30d)
42

Description

System information

  • Python Version: 3.8.13
  • SDK Version: 4.11.3

Describe the bug
Argument camel_case=False for multiple Cognite classes that subclass dict doesn't work because of declared properties with camelCase names, e.g. Label and ExtractionPipelineContact.

To Reproduce
Runnable code reproducing the error.

>>> from cognite.client.data_classes import Label
>>> ll = Label(external_id="what-the-fox")
>>> ll.dump(camel_case=False)
{'externalId': 'what-the-fox'}  # not snake cased
>>> ll.dump(camel_case=True)
{'externalId': 'what-the-fox'}

Or (notice sendNotification always in camel case):

>>> from cognite.client.data_classes import ExtractionPipelineContact
>>> epc = ExtractionPipelineContact(name="Fox", email="NA", role="Singer", send_notification=False)
>>> epc.dump(camel_case=False)
{'name': 'Fox', 'email': 'NA', 'role': 'Singer', 'sendNotification': False}
>>> epc.dump(camel_case=True)
{'name': 'Fox', 'email': 'NA', 'role': 'Singer', 'sendNotification': False}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dump behavior of the Label and ExtractionPipelineContact examples, then trace how dict subclasses handle the camel_case argument. Run the provided reproducer and add regression coverage showing that camel_case=False produces snake_case keys while camel_case=True preserves camelCase output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.