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.

Wrong behaviour with allow_population_by_field_name

See original GitHub issue
from typing import Dict, Any

from pydantic import BaseConfig, BaseModel, Extra, Field

BaseConfig.extra = Extra.forbid
BaseConfig.allow_population_by_field_name = True

class ItemChannelLinkDefinition(BaseModel):
    item_name: str = Field(alias='itemName')
    configuration: Dict[str, Any] = {}


ItemChannelLinkDefinition(item_name='asdf')

The Config switch allow_population_by_field_name means that it’s allowed to use the field name in the constructor. Unfortunately the plugin shows an error.

grafik

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
samuelcolvincommented, Apr 26, 2020

Use a shared custom base model with its own config.

0reactions
koxudaxicommented, Apr 26, 2020

Thank you for your answer. I close this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

allow_population_by_field_name expected behavior? #920
This seems no longer the case (see example below) since allow_population_by_field_name seems to allow population only by field name.
Read more >
Is it possible to change the output alias in pydantic?
I only need this alias to correctly map the incoming data but when returning a response, I want to use actual field names....
Read more >
COMMON ERRORS IN KRONOS AND HOW TO FIX THEM
Employee Error Details. Entering work hours before they have actually been worked. Employees are not allowed to record their work time until they...
Read more >
How to Report Errors in Forms: 10 Design Guidelines
Help users recover from errors by clearly identifying the problems and allowing users to access and correct erroneous fields easily.
Read more >
Preferred Terms for Select Population Groups & Communities
Using preferred terms for select population groups and communities is an important part of respectful communication. This section provides some recommended ...
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