Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Context. In order to define a default implementation (the one used if no other implementation matches), we currently have to write something like this:
fromclassesimporttypeclass@typeclassdefrender(data_value) ->str: """Render a data value nicely."""@render.instance(int)def_render_int(data_value: int) ->str: returnf'This is an integer: {data_value}'@render.instance(object)def_render_int(data_value: object) ->str: returnf'No idea what this is: {data_value}'assertrender('BADOOM') =='No idea what this is: BADOOM'(this script should be runnable as-is.)
Decision. Support Any as a special case to replace object:
@render.instance(Any)def_render_int(data_value: Any) ->str: # type: ignorereturnf'No idea what this is: {data_value}'Consequences.
- Pro: The code will look a little bit more straightforward;
- Contra:
mypywith common settings might be unhappy aboutAnybeing used, but that can be silenced withtype: ignoreI suppose.
Metadata
Metadata
Assignees
Labels
No labels