
GITHUB . COM {
}
Detected CMS Systems:
- Wordpress (2 occurrences)
Title:
BaseModel.construct(): Incorrect field order with default values Β· Issue #2281 Β· pydantic/pydantic
Description:
Checks I added a descriptive title to this issue I have searched (google, github) for similar issues and couldn't find anything I have read and followed the docs and still think this is a bug B...
Website Age:
17 years and 8 months (reg. 2007-10-09).
Matching Content Categories {π}
- Cryptocurrency
- Dating & Relationships
- Business & Finance
Content Management System {π}
What CMS is github.com built with?
Github.com employs 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,019 visitors per month in the current month.
However, some sources were not loaded, we suggest to reload the page to get complete results.
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,889 paying customers.
The estimated monthly recurring revenue (MRR) is $20,957,532.
The estimated annual recurring revenues (ARR) are $251,490,385.
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 {π}
order, pydantic, field, issue, bug, basemodelconstruct, output, sign, default, added, fields, instance, incorrect, values, github, docs, json, export, assert, fix, navigation, issues, pull, requests, actions, security, closed, jonastk, python, import, version, problem, construct, correct, int, instanceconstruct, error, related, prettywood, commit, references, samuelcolvin, type, projects, milestone, footer, skip, content, menu, product,
Topics {βοΈ}
pydantic version incorrect field order personal information basemodel pre-validated input comment metadata assignees bacbd1e prettywood mentioned properly validated instance error assert instance similar issues pydantic v1 verified ad7862f sign import pydantic field order python default values prettywood added instance generated opened checks descriptive title docs ['typing-extensions'] comparing instances projects milestone milestone relationships pydantic issue type projects json export basemodel `basemodel added github order default instance instance instance_construct == instance_construct fix print 14 print 14 print 14} print sign type json skip jump construct searched
Payment Methods {π}
- Braintree
Questions {β}
- Already have an account?
- Construct() with pre-validated input be identical to the JSON export of a properly validated instance?
Schema {πΊοΈ}
DiscussionForumPosting:
context:https://schema.org
headline:BaseModel.construct(): Incorrect field order with default values
articleBody:### Checks
* [x] I added a descriptive title to this issue
* [x] I have searched (google, github) for similar issues and couldn't find anything
* [x] I have read and followed [the docs](https://pydantic-docs.helpmanual.io/) and still think this is a bug
<!-- Sorry to sound so draconian, but every second saved replying to issues is time spend improving pydantic :-) -->
# Bug
Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
pydantic version: 1.7.3
pydantic compiled: True
install path: C:\Users\JonasTK\miniconda3\envs\testenv\Lib\site-packages\pydantic
python version: 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
platform: Windows-10-10.0.19041-SP0
optional deps. installed: ['typing-extensions']
```
<!-- or if you're using pydantic prior to v1.3, manually include: OS, python version and pydantic version -->
<!-- Please read the [docs](https://pydantic-docs.helpmanual.io/) and search through issues to
confirm your bug hasn't already been reported. -->
<!-- Where possible please include a self-contained code snippet describing your bug: -->
I know this is (sort of) showcased in the docs, but I still think it is a problem that .construct() does not give correct field order when there are fields with default values. Most of the time this is not a problem: comparing instances and .dict() outputs do not depend on the field order. But for JSON export, it does matter.
Shouldn't the JSON export from an instance generated via .construct() with pre-validated input be identical to the JSON export of a properly validated instance?
```py
from pydantic import BaseModel
class Foo(BaseModel):
a: int
b: int = 42
c: float
instance = Foo(a=1, c=3.14) # Correct field order
instance_construct = Foo.construct(**instance.dict()) # Incorrect field order
print(instance) # Output: a=1 b=42 c=3.14
print(instance_construct) # Output: b=42 a=1 c=3.14
print(instance.json()) # Output: {"a": 1, "b": 42, "c": 3.14}
print(instance_construct.json()) # Output: {"b": 42, "a": 1, "c": 3.14}
assert instance == instance_construct # No Error
assert instance.dict() == instance_construct.dict() # No Error
assert instance.json() == instance_construct.json() # AssertionError
```
author:
url:https://github.com/jonas-t-k
type:Person
name:jonas-t-k
datePublished:2021-01-22T09:19:45.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:0
url:https://github.com/2281/pydantic/issues/2281
context:https://schema.org
headline:BaseModel.construct(): Incorrect field order with default values
articleBody:### Checks
* [x] I added a descriptive title to this issue
* [x] I have searched (google, github) for similar issues and couldn't find anything
* [x] I have read and followed [the docs](https://pydantic-docs.helpmanual.io/) and still think this is a bug
<!-- Sorry to sound so draconian, but every second saved replying to issues is time spend improving pydantic :-) -->
# Bug
Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
pydantic version: 1.7.3
pydantic compiled: True
install path: C:\Users\JonasTK\miniconda3\envs\testenv\Lib\site-packages\pydantic
python version: 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
platform: Windows-10-10.0.19041-SP0
optional deps. installed: ['typing-extensions']
```
<!-- or if you're using pydantic prior to v1.3, manually include: OS, python version and pydantic version -->
<!-- Please read the [docs](https://pydantic-docs.helpmanual.io/) and search through issues to
confirm your bug hasn't already been reported. -->
<!-- Where possible please include a self-contained code snippet describing your bug: -->
I know this is (sort of) showcased in the docs, but I still think it is a problem that .construct() does not give correct field order when there are fields with default values. Most of the time this is not a problem: comparing instances and .dict() outputs do not depend on the field order. But for JSON export, it does matter.
Shouldn't the JSON export from an instance generated via .construct() with pre-validated input be identical to the JSON export of a properly validated instance?
```py
from pydantic import BaseModel
class Foo(BaseModel):
a: int
b: int = 42
c: float
instance = Foo(a=1, c=3.14) # Correct field order
instance_construct = Foo.construct(**instance.dict()) # Incorrect field order
print(instance) # Output: a=1 b=42 c=3.14
print(instance_construct) # Output: b=42 a=1 c=3.14
print(instance.json()) # Output: {"a": 1, "b": 42, "c": 3.14}
print(instance_construct.json()) # Output: {"b": 42, "a": 1, "c": 3.14}
assert instance == instance_construct # No Error
assert instance.dict() == instance_construct.dict() # No Error
assert instance.json() == instance_construct.json() # AssertionError
```
author:
url:https://github.com/jonas-t-k
type:Person
name:jonas-t-k
datePublished:2021-01-22T09:19:45.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:0
url:https://github.com/2281/pydantic/issues/2281
Person:
url:https://github.com/jonas-t-k
name:jonas-t-k
url:https://github.com/jonas-t-k
name:jonas-t-k
InteractionCounter:
interactionType:https://schema.org/CommentAction
userInteractionCount:0
interactionType:https://schema.org/CommentAction
userInteractionCount:0
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