question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't send not specified properties

See original GitHub issue

E.g.

types.Completion('defaultdict')

will result in sending all other attributes along with label:

server-reply (id:21) Wed May 13 14:25:56 2020:
(:id 21 :jsonrpc "2.0" :result
     (:isIncomplete :json-false :items
		    [(:label "defaultdict" :kind nil :detail nil :documentation nil :deprecated :json-false :preselect :json-false :sortText nil :filterText nil :insertText nil :insertTextFormat nil :textEdit nil :additionalTextEdits nil :commitCharacters nil :command nil :data nil)]))

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pappasamcommented, Aug 20, 2020

@danixeee Another option is to have a library-specific value for an optionally undefined attribute:

UNDEFINED = object()

In the serializer, you can do an identity is check for UNDEFINED and not return it if the object is undefined:

def default_serializer(o):
    """JSON serializer for complex objects."""
    if isinstance(o, enum.Enum):
        return o.value
    d = {}
    for k, v in o.__dict__.items():
        if v is not UNDEFINED:
            d[k] = v
    return d

The above will still allow None to be placed into the dictionary.

I was drawn to this conversation by the following issue: https://github.com/pappasam/jedi-language-server/issues/38#issuecomment-675588654

Here’s a mypy-friendly way of achieving the above: https://www.python.org/dev/peps/pep-0484/#support-for-singleton-types-in-unions

1reaction
rwolscommented, May 14, 2020

There’s also a "range": null in the response to the textDocument/hover request. I’m guessing it’s the same underlying issue.

This library needs to distinguish between optional keys with typed values and mandatory keys.

Read more comments on GitHub >

github_iconTop Results From Across the Web

prevent property from being serialized in web API
It gives me a clean REST API. At the same time when I save the data in a no-sql, the ignored properties are...
Read more >
Jackson Ignore Properties on Marshalling - Baeldung
This tutorial will show how to ignore certain fields when serializing an object to JSON using Jackson 2.x.
Read more >
Mark your email as Normal, Personal, Private, or Confidential
Set the sensitivity level of a message. From your draft email message, click File > Properties. Under Settings, in the Sensitivity list, select...
Read more >
[GA4] Identify unwanted referrals - Analytics Help
Configure unwanted referrals. To configure unwanted referrals, you need the Editor role on the property. In Admin, click Data Streams in the Property...
Read more >
<input>: The Input (Form Input) element - HTML
Attributes ; placeholder, text , search , url , tel , email , password , number, Text that appears in the form control...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found