question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can typos be caught?

See original GitHub issue

This started with my PR #727. Before implementing another suggestion, I feel like there should first be a rough consensus about what the solution should be.

First, the problem: People make typos. When someone writes Flow(variable_cost=42), the missing s (did you spot it?) is silently ignored and one gets a wrong result. Thus, the suggestion is to catch these typos. Somehow.

The problem is complicated by people wanting to be able to add arbitrary properties to objects. So, print(Flow(my_cool_property=42).my_cool_property) should produce 42.

So, here are some random thoughts about possible aspects of a solution:

  • When should typos be checked?
    • At each single object construction
    • When the Model instance is constructured from the energy system
    • When solving a model
    • With an explicit call to check_for_unknown_properties()
  • How should the checking work?
    • Instead of having Flow.__init__(**kwargs):, only the known properties are available as named arguments. New properties could be added via a special custom_properties argument. (Of course, the name for this argument is open for bike-shedding)
    • There could be an internal list of known properties. Everything not known is “bad”. Users could add own properties.
      • …in a global list of known properties
      • …as an argument somewhere somehow to the check itself
  • What should the result of the check be?
    • Exception
    • SuspiciousUsageWarning
    • a list/dict/… of $SOMETHING that is returned to the caller
    • Nothing (the current state of things: no typo checks done)

Uhm… that’s it. These are all the possibilities I could come up with. Feel free to think about this and add more options. If you have the powers to do so, feel free to edit this comment so that there is “a single list of everything”.

No idea how the usual oemof decision making works. Depending on mood, time, and the phase of the moon, I might or might not be able to send a PR for whatever version is preferred.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
p-snftcommented, Dec 3, 2020

The decision has been made: Arguments will be explicit. We aim to do the change for v0.5.0.

2reactions
p-snftcommented, Nov 16, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

6 tips for catching your writing mistakes (and protecting ...
1. Reread it. Read your story one last time, all the way through — just like a reader would. · 2. Change the...
Read more >
Top Five Ways to Catch Typos and Errors in Your Own ...
Top Five Ways to Catch Typos and Errors in Your Own Writing · 1. Print It Out · 2. Utilize Grammar and Spell...
Read more >
What's Up With That: Why It's So Hard to Catch Your Own ...
The reason typos get through isn't because we're stupid or careless, it's because what we're doing is actually very smart, explains psychologist ...
Read more >
10 Ways to Catch the Most Common Typos and Errors
From using a text reader to changing locations, there are several ways to catch the most common typos and errors.
Read more >
8 Tips for Catching Typos Before You Click Send
8 Tips for Catching Typos Before You Click Send · Love your keyboard or replace it. · Always use spell checking. · Unless...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found