module_that_can_be_invoked_from_cli module#

Calculate arithmetic expressions from command line.

class CalculatorType(value)[source]#

Bases: str, enum.Enum

Define supported calculator types.

BINARY = 'binary'#
GENERAL = 'general'#
class BinaryInputs(*, calculator_type, first_number, operator, second_number)[source]#

Bases: pydantic.main.BaseModel

Define arguments for binary calculator.

calculator_type#

kind of calculator

Type:

typing.Literal[CalculatorType.BINARY]

first_number#

first number for the calculation

Type:

float

operator#

arithmetic operator to be used

Type:

BinaryArithmeticOperator

second_number#

second number for the calculation

Type:

float

calculator_type: Literal[module_that_can_be_invoked_from_cli.CalculatorType.BINARY]#
first_number: float#
operator: package_name_to_import_with.calculator_sub_package.wrapper_module.BinaryArithmeticOperator#
second_number: float#
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]] = {'calculator_type': FieldInfo(annotation=Literal[<CalculatorType.BINARY: 'binary'>], required=True), 'first_number': FieldInfo(annotation=float, required=True), 'operator': FieldInfo(annotation=BinaryArithmeticOperator, required=True), 'second_number': FieldInfo(annotation=float, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class GeneralInputs(*, calculator_type, expression)[source]#

Bases: pydantic.main.BaseModel

Define arguments of general calculator.

calculator_type#

kind of calculator

Type:

typing.Literal[CalculatorType.GENERAL]

expression#

mathematical expression to be evaluated

Type:

str

calculator_type: Literal[module_that_can_be_invoked_from_cli.CalculatorType.GENERAL]#
expression: str#
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]] = {'calculator_type': FieldInfo(annotation=Literal[<CalculatorType.GENERAL: 'general'>], required=True), 'expression': FieldInfo(annotation=str, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class UserInputs(*, inputs)[source]#

Bases: pydantic.main.BaseModel

Define sub-commands and arguments of CLI calculator.

inputs#

inputs for the calculator

Type:

BinaryInputs | GeneralInputs

inputs: module_that_can_be_invoked_from_cli.BinaryInputs | module_that_can_be_invoked_from_cli.GeneralInputs#
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]] = {'inputs': FieldInfo(annotation=Union[BinaryInputs, GeneralInputs], required=True, discriminator='calculator_type')}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

capture_user_inputs()[source]#

Capture user inputs for arithmetic expression.

Returns:

captured user inputs

Return type:

UserInputs

console_calculator()[source]#

Calculate arithmetic expressions.