
GITHUB . COM {
}
Detected CMS Systems:
- Wordpress (2 occurrences)
Title:
Inherited models as fields are reconstructed as base model Β· Issue #265 Β· pydantic/pydantic
Description:
I have a model which has a field of a another base-class model. I want this field to be able to contain any sub-class of this model. But when I assign to this field it gets reconstructed to the base model. from pydantic import BaseModel,...
Website Age:
17 years and 8 months (reg. 2007-10-09).
Matching Content Categories {π}
- Photography
- Crafts
- Style & Fashion
Content Management System {π}
What CMS is github.com built with?
Github.com is built with WORDPRESS.
Traffic Estimate {π}
What is the average monthly size of github.com audience?
ππ Tremendous Traffic: 10M - 20M visitors per month
Based on our best estimate, this website will receive around 10,000,003 visitors per month in the current month.
check SE Ranking
check Ahrefs
check Similarweb
check Ubersuggest
check Semrush
How Does Github.com Make Money? {πΈ}
Subscription Packages {π³}
We've located a dedicated page on github.com that might include details about subscription plans or recurring payments. We identified it based on the word pricing in one of its internal links. Below, you'll find additional estimates for its monthly recurring revenues.How Much Does Github.com Make? {π°}
Subscription Packages {π³}
Prices on github.com are in US Dollars ($).
They range from $4.00/month to $21.00/month.
We estimate that the site has approximately 4,989,880 paying customers.
The estimated monthly recurring revenue (MRR) is $20,957,498.
The estimated annual recurring revenues (ARR) are $251,489,970.
Wordpress Themes and Plugins {π¨}
What WordPress theme does this site use?
It is strange but we were not able to detect any theme on the page.
What WordPress plugins does this website use?
It is strange but we were not able to detect any plugins on the page.
Keywords {π}
model, models, fields, koliyo, issue, class, samuelcolvin, pydantic, reconstructed, base, field, foo, feat, avoid, reconstructing, sign, inherited, cfoo, commented, mentioned, prettywood, import, basemodel, printfc, bhello, author, type, return, added, feature, navigation, open, pull, requests, actions, security, closed, subclass, validator, foobasemodel, int, foosubfoo, str, containerbasemodel, foosuba, containerfoofs, printffs, idfs, printfcfoo, idcfoo,
Topics {βοΈ}
utility decorator/type declaration 548b336 samuelcolvin closed 4da511e prettywood mentioned issue open avoid reconstructing models integrate pydantic basemodels pydantic import basemodel inherited models subclass members intact special flag/configuration comment metadata assignees python type hinting base-class model covariant return types samuelcolvin mentioned main field-api feature packaged base model child models custom validators type projects class foosub custom decorator foosub instance c1 = container explicitly list supported subclasses good idea documented usage origially provided projects milestone milestone relationships fs = foosub c2 = container return cls a5b51bc feat e189506 feat pydantic f'fs prints fs nested basemodel f'c1 current behaviour gmso github f'c2 dict_validator foo=fs assigned validate
Payment Methods {π}
- Braintree
Questions {β}
- Already have an account?
- Could this be solved with some custom decorator perhaps?
- Does Python type hinting allow covariant return types?
- How can I achieve this?
- Question/Bug(?
- There might be some construct for this using Generic and/or TypeVar?
Schema {πΊοΈ}
DiscussionForumPosting:
context:https://schema.org
headline:Inherited models as fields are reconstructed as base model
articleBody:I have a model which has a field of a another base-class model. I want this field to be able to contain any sub-class of this model. But when I assign to this field it gets reconstructed to the base model.
```py
from pydantic import BaseModel, validator, PyObject, ValidationError, BaseConfig
class Foo(BaseModel):
a: int
class FooSub(Foo):
b: str
class Container(BaseModel):
foo: Foo
f = Foo(a=1)
c1 = Container(foo=f)
# print(f'c1: {c1}')
fs = FooSub(a=2, b='hello')
c2 = Container(foo=fs)
# print(f'c2: {c2}')
print(f'fs: {fs} (id: {id(fs)})')
print(f'c2.foo: {c2.foo} ({id(c2.foo)})')
```
this prints
```
fs: FooSub a=2 b='hello' (id: 4566162824)
c2.foo: Foo a=2 (4566162696)
```
What I want is `c2.foo` to be the `FooSub` instance I created and assigned. How can I achieve this? I have tried using custom validators, but without success.
author:
url:https://github.com/koliyo
type:Person
name:koliyo
datePublished:2018-09-20T06:11:05.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:4
url:https://github.com/265/pydantic/issues/265
context:https://schema.org
headline:Inherited models as fields are reconstructed as base model
articleBody:I have a model which has a field of a another base-class model. I want this field to be able to contain any sub-class of this model. But when I assign to this field it gets reconstructed to the base model.
```py
from pydantic import BaseModel, validator, PyObject, ValidationError, BaseConfig
class Foo(BaseModel):
a: int
class FooSub(Foo):
b: str
class Container(BaseModel):
foo: Foo
f = Foo(a=1)
c1 = Container(foo=f)
# print(f'c1: {c1}')
fs = FooSub(a=2, b='hello')
c2 = Container(foo=fs)
# print(f'c2: {c2}')
print(f'fs: {fs} (id: {id(fs)})')
print(f'c2.foo: {c2.foo} ({id(c2.foo)})')
```
this prints
```
fs: FooSub a=2 b='hello' (id: 4566162824)
c2.foo: Foo a=2 (4566162696)
```
What I want is `c2.foo` to be the `FooSub` instance I created and assigned. How can I achieve this? I have tried using custom validators, but without success.
author:
url:https://github.com/koliyo
type:Person
name:koliyo
datePublished:2018-09-20T06:11:05.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:4
url:https://github.com/265/pydantic/issues/265
Person:
url:https://github.com/koliyo
name:koliyo
url:https://github.com/koliyo
name:koliyo
InteractionCounter:
interactionType:https://schema.org/CommentAction
userInteractionCount:4
interactionType:https://schema.org/CommentAction
userInteractionCount:4
External Links {π}(3)
Analytics and Tracking {π}
- Site Verification - Google
Libraries {π}
- Clipboard.js
- D3.js
- Lodash
Emails and Hosting {βοΈ}
Mail Servers:
- aspmx.l.google.com
- alt1.aspmx.l.google.com
- alt2.aspmx.l.google.com
- alt3.aspmx.l.google.com
- alt4.aspmx.l.google.com
Name Servers:
- dns1.p08.nsone.net
- dns2.p08.nsone.net
- dns3.p08.nsone.net
- dns4.p08.nsone.net
- ns-1283.awsdns-32.org
- ns-1707.awsdns-21.co.uk
- ns-421.awsdns-52.com
- ns-520.awsdns-01.net