paste_service¶
- class PasteFile(**data)[source]¶
- Bases: - BaseModel- A file to be pasted to the paste service. - Parameters:
 - __class_vars__: ClassVar[set[str]] = {}¶
- The names of the class variables defined on the model. 
 - __private_attributes__: ClassVar[Dict[str, ModelPrivateAttr]] = {}¶
- Metadata about the private attributes of the model. 
 - __pydantic_complete__: ClassVar[bool] = True¶
- Whether model building is completed, or if there are still undefined fields. 
 - __pydantic_core_schema__: ClassVar[CoreSchema] = {'cls': <class 'pydis_core.utils.paste_service.PasteFile'>, 'config': {'title': 'PasteFile'}, 'custom_init': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'pydis_core.utils.paste_service.PasteFile'>, title=None), <bound method BaseModel.__get_pydantic_json_schema__ of <class 'pydis_core.utils.paste_service.PasteFile'>>]}, 'ref': 'pydis_core.utils.paste_service.PasteFile:94722946882848', 'root_model': False, 'schema': {'computed_fields': [], 'fields': {'content': {'metadata': {'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>], 'pydantic_js_functions': []}, 'schema': {'type': 'str'}, 'type': 'model-field'}, 'lexer': {'metadata': {'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>], 'pydantic_js_functions': []}, 'schema': {'default': 'python', 'schema': {'type': 'str'}, 'type': 'default'}, 'type': 'model-field'}, 'name': {'metadata': {'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>], 'pydantic_js_functions': []}, 'schema': {'default': '', 'schema': {'type': 'str'}, 'type': 'default'}, 'type': 'model-field'}}, 'model_name': 'PasteFile', 'type': 'model-fields'}, 'type': 'model'}¶
- The core schema of the model. 
 - __pydantic_custom_init__: ClassVar[bool] = False¶
- Whether the model has a custom __init__ method. 
 - __pydantic_decorators__: ClassVar[_decorators.DecoratorInfos] = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})¶
- Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1. 
 - __pydantic_extra__: dict[str, Any] | None¶
- A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’. 
 - __pydantic_fields_set__: set[str]¶
- The names of fields explicitly set during instantiation. 
 - __pydantic_generic_metadata__: ClassVar[_generics.PydanticGenericMetadata] = {'args': (), 'origin': None, 'parameters': ()}¶
- Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these. 
 - __pydantic_parent_namespace__: ClassVar[Dict[str, Any] | None] = None¶
- Parent namespace of the model, used for automatic rebuilding of models. 
 - __pydantic_post_init__: ClassVar[None | Literal['model_post_init']] = None¶
- The name of the post-init method for the model, if defined. 
 - __pydantic_private__: dict[str, Any] | None¶
- Values of private attributes set on the model instance. 
 - __pydantic_serializer__: ClassVar[SchemaSerializer] = SchemaSerializer(serializer=Model( ModelSerializer { class: Py( 0x000056266799dd20, ), serializer: Fields( GeneralFieldsSerializer { fields: { "lexer": SerField { key_py: Py( 0x00007f6a3a19c5f0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f6a39f04730, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, "content": SerField { key_py: Py( 0x00007f6a3a467930, ), alias: None, alias_py: None, serializer: Some( Str( StrSerializer, ), ), required: true, }, "name": SerField { key_py: Py( 0x00007f6a3b356ea0, ), alias: None, alias_py: None, serializer: Some( WithDefault( WithDefaultSerializer { default: Default( Py( 0x00007f6a3b3530c0, ), ), serializer: Str( StrSerializer, ), }, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 3, }, ), has_extra: false, root_model: false, name: "PasteFile", }, ), definitions=[])¶
- The pydantic-core SchemaSerializer used to dump instances of the model. 
 - __pydantic_validator__: ClassVar[SchemaValidator | PluggableSchemaValidator] = SchemaValidator(title="PasteFile", validator=Model( ModelValidator { revalidate: Never, validator: ModelFields( ModelFieldsValidator { fields: [ Field { name: "content", lookup_key: Simple { key: "content", py_key: Py( 0x00007f6a27248730, ), path: LookupPath( [ S( "content", Py( 0x00007f6a272486f0, ), ), ], ), }, name_py: Py( 0x00007f6a3a467930, ), validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), frozen: false, }, Field { name: "name", lookup_key: Simple { key: "name", py_key: Py( 0x00007f6a272487b0, ), path: LookupPath( [ S( "name", Py( 0x00007f6a27248770, ), ), ], ), }, name_py: Py( 0x00007f6a3b356ea0, ), validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f6a3b3530c0, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f6a390d6620, ), }, ), frozen: false, }, Field { name: "lexer", lookup_key: Simple { key: "lexer", py_key: Py( 0x00007f6a272487f0, ), path: LookupPath( [ S( "lexer", Py( 0x00007f6a27248830, ), ), ], ), }, name_py: Py( 0x00007f6a3a19c5f0, ), validator: WithDefault( WithDefaultValidator { default: Default( Py( 0x00007f6a39f04730, ), ), on_error: Raise, validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), validate_default: false, copy_default: false, name: "default[str]", undefined: Py( 0x00007f6a390d6620, ), }, ), frozen: false, }, ], model_name: "PasteFile", extra_behavior: Ignore, extras_validator: None, strict: false, from_attributes: false, loc_by_alias: true, }, ), class: Py( 0x000056266799dd20, ), post_init: None, frozen: false, custom_init: false, root_model: false, undefined: Py( 0x00007f6a390d6620, ), name: "PasteFile", }, ), definitions=[], cache_strings=True)¶
- The pydantic-core SchemaValidator used to validate instances of the model. 
 - __signature__: ClassVar[Signature] = <Signature (*, content: str, name: str = '', lexer: str = 'python') -> None>¶
- The synthesized __init__ [Signature][inspect.Signature] of the model. 
 - model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}¶
- A dictionary of computed field names and their corresponding ComputedFieldInfo objects. 
 - model_config: ClassVar[ConfigDict] = {}¶
- Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict]. 
 - model_fields: ClassVar[Dict[str, FieldInfo]] = {'content': FieldInfo(annotation=str, required=True), 'lexer': FieldInfo(annotation=str, required=False, default='python'), 'name': FieldInfo(annotation=str, required=False, default='')}¶
- Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects. - This replaces Model.__fields__ from Pydantic V1. 
 
- class PasteResponse(**data)[source]¶
- Bases: - BaseModel- A successful response from the paste service. - Parameters:
 - __class_vars__: ClassVar[set[str]] = {}¶
- The names of the class variables defined on the model. 
 - __private_attributes__: ClassVar[Dict[str, ModelPrivateAttr]] = {}¶
- Metadata about the private attributes of the model. 
 - __pydantic_complete__: ClassVar[bool] = True¶
- Whether model building is completed, or if there are still undefined fields. 
 - __pydantic_core_schema__: ClassVar[CoreSchema] = {'cls': <class 'pydis_core.utils.paste_service.PasteResponse'>, 'config': {'title': 'PasteResponse'}, 'custom_init': False, 'metadata': {'pydantic_js_annotation_functions': [], 'pydantic_js_functions': [functools.partial(<function modify_model_json_schema>, cls=<class 'pydis_core.utils.paste_service.PasteResponse'>, title=None), <bound method BaseModel.__get_pydantic_json_schema__ of <class 'pydis_core.utils.paste_service.PasteResponse'>>]}, 'ref': 'pydis_core.utils.paste_service.PasteResponse:94722947108080', 'root_model': False, 'schema': {'computed_fields': [], 'fields': {'link': {'metadata': {'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>], 'pydantic_js_functions': []}, 'schema': {'type': 'str'}, 'type': 'model-field'}, 'removal': {'metadata': {'pydantic_js_annotation_functions': [<function get_json_schema_update_func.<locals>.json_schema_update_func>], 'pydantic_js_functions': []}, 'schema': {'type': 'str'}, 'type': 'model-field'}}, 'model_name': 'PasteResponse', 'type': 'model-fields'}, 'type': 'model'}¶
- The core schema of the model. 
 - __pydantic_custom_init__: ClassVar[bool] = False¶
- Whether the model has a custom __init__ method. 
 - __pydantic_decorators__: ClassVar[_decorators.DecoratorInfos] = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})¶
- Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1. 
 - __pydantic_extra__: dict[str, Any] | None¶
- A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’. 
 - __pydantic_fields_set__: set[str]¶
- The names of fields explicitly set during instantiation. 
 - __pydantic_generic_metadata__: ClassVar[_generics.PydanticGenericMetadata] = {'args': (), 'origin': None, 'parameters': ()}¶
- Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these. 
 - __pydantic_parent_namespace__: ClassVar[Dict[str, Any] | None] = None¶
- Parent namespace of the model, used for automatic rebuilding of models. 
 - __pydantic_post_init__: ClassVar[None | Literal['model_post_init']] = None¶
- The name of the post-init method for the model, if defined. 
 - __pydantic_private__: dict[str, Any] | None¶
- Values of private attributes set on the model instance. 
 - __pydantic_serializer__: ClassVar[SchemaSerializer] = SchemaSerializer(serializer=Model( ModelSerializer { class: Py( 0x00005626679d4cf0, ), serializer: Fields( GeneralFieldsSerializer { fields: { "link": SerField { key_py: Py( 0x00007f6a3b2ac2a0, ), alias: None, alias_py: None, serializer: Some( Str( StrSerializer, ), ), required: true, }, "removal": SerField { key_py: Py( 0x00007f6a27c31cf0, ), alias: None, alias_py: None, serializer: Some( Str( StrSerializer, ), ), required: true, }, }, computed_fields: Some( ComputedFields( [], ), ), mode: SimpleDict, extra_serializer: None, filter: SchemaFilter { include: None, exclude: None, }, required_fields: 2, }, ), has_extra: false, root_model: false, name: "PasteResponse", }, ), definitions=[])¶
- The pydantic-core SchemaSerializer used to dump instances of the model. 
 - __pydantic_validator__: ClassVar[SchemaValidator | PluggableSchemaValidator] = SchemaValidator(title="PasteResponse", validator=Model( ModelValidator { revalidate: Never, validator: ModelFields( ModelFieldsValidator { fields: [ Field { name: "link", lookup_key: Simple { key: "link", py_key: Py( 0x00007f6a272330f0, ), path: LookupPath( [ S( "link", Py( 0x00007f6a272330b0, ), ), ], ), }, name_py: Py( 0x00007f6a3b2ac2a0, ), validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), frozen: false, }, Field { name: "removal", lookup_key: Simple { key: "removal", py_key: Py( 0x00007f6a27233170, ), path: LookupPath( [ S( "removal", Py( 0x00007f6a27233130, ), ), ], ), }, name_py: Py( 0x00007f6a27c31cf0, ), validator: Str( StrValidator { strict: false, coerce_numbers_to_str: false, }, ), frozen: false, }, ], model_name: "PasteResponse", extra_behavior: Ignore, extras_validator: None, strict: false, from_attributes: false, loc_by_alias: true, }, ), class: Py( 0x00005626679d4cf0, ), post_init: None, frozen: false, custom_init: false, root_model: false, undefined: Py( 0x00007f6a390d6620, ), name: "PasteResponse", }, ), definitions=[], cache_strings=True)¶
- The pydantic-core SchemaValidator used to validate instances of the model. 
 - __signature__: ClassVar[Signature] = <Signature (*, link: str, removal: str) -> None>¶
- The synthesized __init__ [Signature][inspect.Signature] of the model. 
 - model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}¶
- A dictionary of computed field names and their corresponding ComputedFieldInfo objects. 
 - model_config: ClassVar[ConfigDict] = {}¶
- Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict]. 
 - model_fields: ClassVar[Dict[str, FieldInfo]] = {'link': FieldInfo(annotation=str, required=True), 'removal': FieldInfo(annotation=str, required=True)}¶
- Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects. - This replaces Model.__fields__ from Pydantic V1. 
 
- exception PasteTooLongError[source]¶
- Bases: - Exception- Raised when content is too large to upload to the paste service. 
- exception PasteUnsupportedLexerError[source]¶
- Bases: - Exception- Raised when an unsupported lexer is used. 
- exception PasteUploadError[source]¶
- Bases: - Exception- Raised when an error is encountered uploading to the paste service. 
- async send_to_paste_service(*, files, http_session, paste_url='https://paste.pythondiscord.com', max_size=524288)[source]¶
- Upload some contents to the paste service. - Parameters:
- files ( - list[- PasteFile]) – The files to be uploaded to the paste service.
- http_session (aiohttp.ClientSession) – The session to use when POSTing the content to the paste service. 
- paste_url ( - str) – The base url to the paste service.
- max_size ( - int) – The max number of bytes to be allowed. Anything larger than- MAX_PASTE_SIZEwill be rejected.
 
- Raises:
- ValueError – - max_lengthgreater than the maximum allowed by the paste service.
- PasteTooLongError – - contentstoo long to upload.
- PasteUploadError – Uploading failed. 
 
- Return type:
- Returns:
- A pydantic model containing both the URL of the paste, and a URL to remove the paste.