Git Product home page Git Product logo

oblate's Introduction

oblate's People

Contributors

izxxr avatar

Stargazers

 avatar  avatar

Watchers

 avatar

oblate's Issues

Add support for using type annotations to register fields

Description

Allow using type annotations for registering the fields similar to how dataclasses and pydantic register fields.

This needs consideration on which standard type maps to which Oblate field along with several other design constraints such as dealing with PEP 563. Should be implemented before #6

Types mapping table

F: field mapping to some type

Standard (Python) type Oblate Field
str fields.String
int fields.Integer
float fields.Float
bool fields.Boolean
oblate.Schema fields.Object
list fields.List
set fields.Set
dict fields.Dict
typing.TypedDict fields.TypedDict
typing.Union fields.Union
typing.Literal fields.Literal
typing.Any fields.Any
Type expressions [1] fields.TypeExpr
Optional[F] F(null=True)
field_name: F = v F(default=v)
NotStrict[F] [2] F(strict=False)
NotRequired[F] [2] F(required=False)
NotRequired[F] [2] F(required=False)

[1] It needs consideration whether there should be a generic class that maps to the TypeExpr field
[2] These types would be provided by the new oblate.types module (e.g. oblate.types.NotRequired etc.)

Add support for initializing schema using keyword arguments

This was a feature in 0.x version but was removed in 1.x rewrite due to various design constraints but with the introduction of contextual objects and various other features that resolves those design issues, this could be reconsidered.

Fields and Validators to implement

Fields

  • fields.primitive.String
  • fields.primitive.Integer
  • fields.primitive.Float
  • fields.primitive.Boolean

  • fields.nesting.Object
  • fields.nesting.Partial

  • fields.types.Union
  • fields.types.Any
  • fields.types.Literal
  • fields.types.TypeExpr

  • fields.structs.Dict
  • fields.structs.TypedDict
  • fields.structs.List
  • fields.structs.Set
  • fields.structs.Tuple

  • fields.stdlib.Date
  • fields.stdlib.DateTime
  • fields.stdlib.Enum
  • fields.stdlib.UUID

  • fields.special.Email
  • fields.special.URL
  • fields.special.PhoneNumber
  • fields.special.PaymentCardNumber
  • fields.special.Color
  • fields.special.Coordinates
  • fields.special.FilePath

Validators

  • validate.Length
  • validate.RegEx
  • validate.Range
  • validate.Exclude
  • validate.Or

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.