
GITHUB . COM {
}
Detected CMS Systems:
- Wordpress (2 occurrences)
Title:
Recursion errors for self-referencing generic models Β· Issue #1345 Β· pydantic/pydantic
Description:
Question Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())": pydantic version: 1.4 pydantic compiled: False install path: F:\Software\Miniconda3\Lib\site-packages\pydantic python version: 3.7.6 | packaged b...
Website Age:
17 years and 8 months (reg. 2007-10-09).
Matching Content Categories {π}
- Technology & Computing
- Video & Online Content
- Cryptocurrency
Content Management System {π}
What CMS is github.com built with?
Github.com is based on 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 {π}
import, pydantic, schema, description, children, question, samuelcolvin, generic, issue, node, sign, recursion, class, generict, listnodet, nodes, error, type, commented, issues, models, umvarma, python, navigation, open, code, pull, requests, discussions, actions, security, errors, selfreferencing, closed, version, shown, future, annotations, basemodel, typing, list, typevar, pydanticgenerics, genericmodel, typevart, nodegenericmodel, nodeupdateforwardrefs, treegenericmodel, top, level,
Topics {βοΈ}
completed samuelcolvin mentioned open issues lyz-code mentioned samuelcolvin closed pydantic import basemodel comment metadata assignees __future__ import annotations typing import list pydantic version n1 = node[str] generics import genericmodel referencing models n0 = node[int] n2 = node[int] import pydantic discussions π question discussion list[node] = schema description = 'node python object code tree[int] nodes = [n0] issues node type node[int] list[node[ list[node] class tree type projects [] issue children type children = [n1 class node conda-forge greatly appreciated projects milestone milestone relationships question python error disappers validation error feel free github pydantic nodes node generic generic[ n2]
Payment Methods {π}
- Braintree
Questions {β}
- @dmontagu any idea?
- Already have an account?
- Any news on this?
- I have also encountered this issue - @umvarma did you find a workaround?
Schema {πΊοΈ}
DiscussionForumPosting:
context:https://schema.org
headline:Recursion errors for self-referencing generic models
articleBody:# Question
Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
pydantic version: 1.4
pydantic compiled: False
install path: F:\Software\Miniconda3\Lib\site-packages\pydantic
python version: 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 21:48:41) [MSC v.1916 64 bit (AMD64)]
platform: Windows-10-10.0.18362-SP0
optional deps. installed: []
```
## Issue
I wrote a generic model named Tree as shown in the following snippet.
```py
from __future__ import annotations
from pydantic import BaseModel, Schema
from typing import List, Generic, TypeVar
from pydantic.generics import GenericModel
T = TypeVar('T')
class Node(GenericModel, Generic[T]):
value: T = Schema(..., description = 'Node value')
children: List[Node[T]] = Schema([], description = 'Node children')
Node.update_forward_refs()
class Tree(GenericModel, Generic[T]):
nodes: List[Node[T]] = Schema([], description = 'Top level nodes')
```
I get the error "maximum recursion depth exceeded while calling a Python object" when I try to use it. Any suggestions on how I can fix this would be greatly appreciated.
If I modify the Node.children type from List[Node[T]] to List[Node], then the error disappers.
```py
from __future__ import annotations
from pydantic import BaseModel, Schema
from typing import List, Generic, TypeVar
from pydantic.generics import GenericModel
T = TypeVar('T')
class Node(GenericModel, Generic[T]):
value: T = Schema(..., description = 'Node value')
children: List[Node] = Schema([], description = 'Node children')
Node.update_forward_refs()
class Tree(GenericModel, Generic[T]):
nodes: List[Node[T]] = Schema([], description = 'Top level nodes')
```
The problem in this case is that, it accepts any Node type as the children as shown in the following code.
```py
n1 = Node[str](value = "j")
n2 = Node[int](value = 2)
n0 = Node[int](value = 0, children = [n1, n2])
Tree[int](nodes = [n0]).dict()
```
I want it to support only `Node[int]` as children, and I want it throw a validation error in the above case.
author:
url:https://github.com/umvarma
type:Person
name:umvarma
datePublished:2020-03-27T06:56:08.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:4
url:https://github.com/1345/pydantic/issues/1345
context:https://schema.org
headline:Recursion errors for self-referencing generic models
articleBody:# Question
Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
pydantic version: 1.4
pydantic compiled: False
install path: F:\Software\Miniconda3\Lib\site-packages\pydantic
python version: 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 21:48:41) [MSC v.1916 64 bit (AMD64)]
platform: Windows-10-10.0.18362-SP0
optional deps. installed: []
```
## Issue
I wrote a generic model named Tree as shown in the following snippet.
```py
from __future__ import annotations
from pydantic import BaseModel, Schema
from typing import List, Generic, TypeVar
from pydantic.generics import GenericModel
T = TypeVar('T')
class Node(GenericModel, Generic[T]):
value: T = Schema(..., description = 'Node value')
children: List[Node[T]] = Schema([], description = 'Node children')
Node.update_forward_refs()
class Tree(GenericModel, Generic[T]):
nodes: List[Node[T]] = Schema([], description = 'Top level nodes')
```
I get the error "maximum recursion depth exceeded while calling a Python object" when I try to use it. Any suggestions on how I can fix this would be greatly appreciated.
If I modify the Node.children type from List[Node[T]] to List[Node], then the error disappers.
```py
from __future__ import annotations
from pydantic import BaseModel, Schema
from typing import List, Generic, TypeVar
from pydantic.generics import GenericModel
T = TypeVar('T')
class Node(GenericModel, Generic[T]):
value: T = Schema(..., description = 'Node value')
children: List[Node] = Schema([], description = 'Node children')
Node.update_forward_refs()
class Tree(GenericModel, Generic[T]):
nodes: List[Node[T]] = Schema([], description = 'Top level nodes')
```
The problem in this case is that, it accepts any Node type as the children as shown in the following code.
```py
n1 = Node[str](value = "j")
n2 = Node[int](value = 2)
n0 = Node[int](value = 0, children = [n1, n2])
Tree[int](nodes = [n0]).dict()
```
I want it to support only `Node[int]` as children, and I want it throw a validation error in the above case.
author:
url:https://github.com/umvarma
type:Person
name:umvarma
datePublished:2020-03-27T06:56:08.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:4
url:https://github.com/1345/pydantic/issues/1345
Person:
url:https://github.com/umvarma
name:umvarma
url:https://github.com/umvarma
name:umvarma
InteractionCounter:
interactionType:https://schema.org/CommentAction
userInteractionCount:4
interactionType:https://schema.org/CommentAction
userInteractionCount:4
External Links {π}(2)
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