Skip to main content

EASY Class package build coverage

EASY Class is a toolkit for creating generic classes in an elegant way.

Usage

from easy_class import EasyClass, StringVariable, IntegerVariable


class MyClass(EasyClass):
    attr1 = IntegerVariable()
    attr2 = StringVariable()

The above code declares a class with two member variables attr1 and attr2, where attr1 can only be an integer value and attr2 can only be a string. Hence, if you try to do the following

obj = MyClass()
obj.attr1 = "Test"

it will raise the exception TypeError: attr1 expects int type, but received str.

Class Variable Reference

All Variable types (i.e. IntegerVariable, StringVariable) are inherited from the class Variable which represents a class attribute type. Below contains all the API references of Variable including the variable options and field types this package offers.

Variable options

The following arguments are available to all variable types. All are optional.

null

If False the attribute cannot be assigned a NULL variable. Default is True. You cannot also instantiate a class which has any Non-nullable attributes without specifying the correct arguments. Below is what I meant to say.

class MyClass(EasyClass):
    attr1 = IntegerVariable(null=False)
    attr2 = StringVariable(null=False)

obj = MyClass()

The above will raise the exception ValueError: Following attributes cannot be null: [attr2, attr1]

choices

A list to use as choices for the attribute. Will raise exception if value being is stored is not included in this list of choices.

default

The default value for the attribute. Right now, callables are not supported.

editable

If False, the attribute value cannot be edited. Default is True.

Variable Types

IntegerVariable

An Integer Variable. IntegerVariable allows the following extra arguments.

max_value

The maximum value that can be set for the attribute. Default is None (i.e., no validation is done)

min_value

The minimum value that can be set for the attribute. Default is None (i.e., no validation is done)

StringVariable

A string variable, for small- to large-sized strings. StringVariable has the following extra arguments

max_length

The maximum length (in characters) of the attribute. Defaults 255.

min_length

The minimum length (in characters) of the attribute. Defaults 0.

BooleanVariable

A true/false attribute.

FloatVariable

A floating-point number represented in Python by a float instance. FloatVariable accepts same arguments as an IntegerField.

ClassVariable

A custom class variable. Required keyword argument cls must be passed to a ClassVariable. Below is an example.
class A(object):
   pass

class MyClass(EasyClass):
   a = ClassVariable(cls=A, null=False)

DictVariable

A dictionary variable.

DateTimeVariable

A python datetime variable. DateTimeVariable either accepts a datetime variable or string of the format YYYY-MM-DDTHH:MM:SS.

DateVariable

A python date variable. DateVariable either accepts a date variable or string of the format YYYY-MM-DD.

TimeVariable

A python time variable. TimeVariable either accepts a time variable or string of the format HH:MM:SS.

Release files for easy-class 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-class 1.1.2
File Size Uploaded
easy_class-1.1.2.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easy-class 1.1.2
File Interpreter ABI Platform
easy_class-1.1.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 22.6 kB

Release files / easy_class-1.1.2.tar.gz

Download URL easy_class-1.1.2.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4ec0b292e9684dc330a077ac36081e531d27068a4a30d65ead58d47d4df1cdc5
BLAKE2b-256 checksum
How to use checksums
5c98c3046b7a8899ed5069c7b16581ac9ebc133075c0a0e86857e6d9efa553de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / easy_class-1.1.2-py2.py3-none-any.whl

Download URL easy_class-1.1.2-py2.py3-none-any.whl
Size 9.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b18fde7b5499861a68da4cb57b74f79f3d47a4ff408baccdaa608b5807ecb0e1
BLAKE2b-256 checksum
How to use checksums
9200d6209c1a12aa16da3bac6fac036f3ff313520b030be9f2f1e4687e2909c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.7

3 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page