8000 Short-cut for the factory function (Feature request) · Issue #60 · biqqles/dataclassy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Short-cut for the factory function (Feature request) #60
Open
@mnieber

Description

@mnieber

First of all, great work!

I wondered if the verbosity of the code could be further reduced by allowing the factory function to be used without arguments. In that case, the argument to factory should be derived from the type annotation. E.g.

@dataclass(kw_only=True)
class GenerateCodeFn(Entity):
    post_process_source_code_fn: PostProcessSourceCodeFn = factory

Of course, this is only a minor improvement, but still potentially a useful one.

By the way, it seems that the following alternative has a drawback (for me), since vscode fails to detect the type of post_process_source_code_fn and therefore symbol lookup doesn't work.

@dataclass(kw_only=True)
class GenerateCodeFn(Entity):
    post_process_source_code_fn = factory(PostProcessSourceCodeFn)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0