lmmx / refactory

Refactor utility with patterns composed of validated AST rules
MIT License
2 stars 0 forks source link

[rule] TypedDict upgrade (dicts with fixed keys) #5

Open lmmx opened 2 years ago

lmmx commented 2 years ago

via

Motivation/rationale:

TypedDict must be constructed directly in one go, and so strictly prohibits conditional kwargs

i.e.

More generally, would like to be able to populate multiple files from the output (in this case: the source file and append the types to a types module) but this could be done in steps (‘pipelining’ separate rules perhaps)

i.e. {"some_name": 0} could be automatically turned into [presuming the name SomeName doesn’t exist):

SomeName = int

class AutoGenDict1(TypedDict):
    some_name: SomeName

Requirements:

lmmx commented 2 years ago