eric7.Plugins.CheckerPlugins.CodeStyleChecker.Pydantic.PydanticVisitor

Module implementing a node visitor to check for pydantic related issues.

Global Attributes

None

Classes

PydanticVisitor Class implementing a node visitor to check for pydantic related issues.

Functions

None


PydanticVisitor

Class implementing a node visitor to check for pydantic related issues.

Derived from

ast.NodeVisitor

Class Attributes

None

Class Methods

None

Methods

PydanticVisitor Constructor
__checkForPyd001 Private method to check positional argument for Field default argument.
__checkForPyd002 Private method to check non-annotated attribute inside Pydantic model.
__checkForPyd003 Private method to check unecessary Field call to specify a default value.
__checkForPyd004 Private method to check for a default argument specified in annotated.
__checkForPyd005 Private method to check for a field name overriding the annotation.
__checkForPyd006 Private method to check for duplicate field names.
__checkForPyd010 Private method to check for the use of `__pydantic_config__`.
__currentClass Private method returning the current class type as recorded by the __enterClass method.
__enterClass Private method to record class type when entering a class definition.
__leaveClass Private method to remove the data recorded by the __enterClass method.
visit_AnnAssign Public method to process annotated assignment.
visit_ClassDef Public method to process class definitions.

Static Methods

None

PydanticVisitor (Constructor)

PydanticVisitor(errorCallback)

Constructor

errorCallback (func)
callback function to register an issue

PydanticVisitor.__checkForPyd001

__checkForPyd001(node: ast.AnnAssign)

Private method to check positional argument for Field default argument.

node (ast.AnnAssign)
reference to the node to be processed

PydanticVisitor.__checkForPyd002

__checkForPyd002(node)

Private method to check non-annotated attribute inside Pydantic model.

node (ast.ClassDef)
reference to the node to be processed

PydanticVisitor.__checkForPyd003

__checkForPyd003(node)

Private method to check unecessary Field call to specify a default value.

node (ast.AnnAssign)
reference to the node to be processed

PydanticVisitor.__checkForPyd004

__checkForPyd004(node)

Private method to check for a default argument specified in annotated.

node (ast.AnnAssign)
reference to the node to be processed

PydanticVisitor.__checkForPyd005

__checkForPyd005(node)

Private method to check for a field name overriding the annotation.

node (ast.ClassDef)
reference to the node to be processed

PydanticVisitor.__checkForPyd006

__checkForPyd006(node)

Private method to check for duplicate field names.

node (ast.ClassDef)
reference to the node to be processed

PydanticVisitor.__checkForPyd010

__checkForPyd010(node: ast.ClassDef)

Private method to check for the use of `__pydantic_config__`.

node (ast.ClassDef)
reference to the node to be processed

PydanticVisitor.__currentClass

__currentClass()

Private method returning the current class type as recorded by the __enterClass method.

Return:
current class type (one of 'pydantic_model', 'dataclass' or 'other_class')
Return Type:
str

PydanticVisitor.__enterClass

__enterClass(node)

Private method to record class type when entering a class definition.

node (ast.ClassDef)
reference to the node to be processed

PydanticVisitor.__leaveClass

__leaveClass()

Private method to remove the data recorded by the __enterClass method.

PydanticVisitor.visit_AnnAssign

visit_AnnAssign(node: ast.AnnAssign)

Public method to process annotated assignment.

node (ast.AnnAssign)
reference to the node to be processed.

PydanticVisitor.visit_ClassDef

visit_ClassDef(node: ast.ClassDef)

Public method to process class definitions.

node (ast.ClassDef)
reference to the node to be processed.
Up