-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from koxudaxi/support_frozen_on_config
Support frozen on config
- Loading branch information
Showing
8 changed files
with
135 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class A(BaseModel): | ||
abc: str = '123' | ||
A.abc = '456' | ||
A().abc = '456' | ||
|
||
class B(BaseModel): | ||
abc: str = '123' | ||
class Config: | ||
allow_mutation=False | ||
B.abc = '456' | ||
<error descr="Property \"abc\" defined in \"B\" is read-only">B().abc = '456'</error> | ||
|
||
class C(BaseModel): | ||
abc: str = '123' | ||
class Config: | ||
allow_mutation=True | ||
C.abc = '456' | ||
C().abc = '456' | ||
|
||
class D(BaseModel): | ||
class Config: | ||
allow_mutation=False | ||
D.abc = '456' | ||
<error descr="Property \"abc\" defined in \"D\" is read-only">D().abc = '456'</error> | ||
|
||
allow_mutation = True | ||
class E(BaseModel): | ||
class Config: | ||
allow_mutation=allow_mutation | ||
E.abc = '456' | ||
E().abc = '456' | ||
|
||
|
||
class F(D): | ||
class Config: | ||
allow_mutation=False | ||
F.abc = '456' | ||
<error descr="Property \"abc\" defined in \"F\" is read-only">F().abc = '456'</error> | ||
|
||
|
||
class G(BaseModel): | ||
class Config: | ||
allow_mutation=False | ||
G.abc =<EOLError descr="Expression expected"></EOLError> | ||
G.abc.lower() | ||
<error descr="Cannot assign to function call">G.abc.lower()</error> = 'efg' | ||
|
||
|
||
class H: | ||
class Config: | ||
allow_mutation=False | ||
H.abc = '123' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class A(BaseModel): | ||
abc: str = '123' | ||
A.abc = '456' | ||
A().abc = '456' | ||
|
||
class B(BaseModel): | ||
abc: str = '123' | ||
class Config: | ||
frozen=True | ||
B.abc = '456' | ||
<error descr="Property \"abc\" defined in \"B\" is read-only">B().abc = '456'</error> | ||
|
||
class C(BaseModel): | ||
abc: str = '123' | ||
class Config: | ||
frozen=False | ||
C.abc = '456' | ||
C().abc = '456' | ||
|
||
class D(BaseModel): | ||
class Config: | ||
frozen=True | ||
D.abc = '456' | ||
<error descr="Property \"abc\" defined in \"D\" is read-only">D().abc = '456'</error> | ||
|
||
frozen = False | ||
class E(BaseModel): | ||
class Config: | ||
frozen=frozen | ||
E.abc = '456' | ||
E().abc = '456' | ||
|
||
|
||
class F(D): | ||
class Config: | ||
frozen=True | ||
F.abc = '456' | ||
<error descr="Property \"abc\" defined in \"F\" is read-only">F().abc = '456'</error> | ||
|
||
|
||
class G(BaseModel): | ||
class Config: | ||
frozen=False | ||
G.abc =<EOLError descr="Expression expected"></EOLError> | ||
G.abc.lower() | ||
<error descr="Cannot assign to function call">G.abc.lower()</error> = 'efg' | ||
|
||
|
||
class H: | ||
class Config: | ||
frozen=True | ||
H.abc = '123' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters