Improve handling of kwargs
See original GitHub issueUpdate: There seem to be four degrees of possible kwarg handling:
-
Use wild card **kwargs for all key word arguments. This is currently done, e.g. in Flow. Currently, this is the most common way in oemof.
-
Define known kwargs but set empty defaults. Technically, this is the same API as in 1. but it improves readability and comfort. This way was suggested later in this ticket. It also reduces the likeliness of typos.
-
Enforce values for obligatory quantities. This would also improve readability, and would also solve copy and paste errors, typos, etc. It would require programmers to make explicit when obligatory parameters should be left uninitialized (e.g.
Sink(inputs={})). It is already implemented in ExtractionTurbineCHP but quite uncommon in oemof. -
Disallow faulty kwargs (like
outputsfor aSink, or those including typos). This option would either cost flexibility, require some “expert mode” where strict enforcement is turned off, or need explicit checks. (Option 4 is what I originally proposed here.)
Original text: I would suggest to raise errors if unknown kwargs are passed to functions. I believe this would make it greatly easier to debug code using oemof and improve the usability.
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (19 by maintainers)

Top Related StackOverflow Question
I agree that mandatory parameters shouldn’t be hidden in kwargs. This would also solve some of @p-snft 's problems. If a Sink does not have an
inputparameter an error is raised even if there is aniMputor anoutputparameter instead.We could also think of forbidden attributes. A Source for example is not allowed to have an
inputparameter and a Sink is not allowed to have anoutputparameter.Anything else?
@oemof/oemof-developer-group What do you think?
The check should solve the known problems. Thank you!