In python the following code works perfectly fine.
class Table: pass table = Table() table.fruits = ["apple", "orange"]
But as soon as we check it out with some kind of linter, errors will start showing. Pylint will complain about attribute defined outside
__init__ method, Mypy will claim we're trying to access attribute that doesn't exist etc.
Meanwhile, there are situations when the logic of our program suggests that this is the most appropriate way. Let's say we have a Playground class object, where we store different information's, depending on to which subclass of the Game class, implementing logic of the game being played on it, we pass it to.
Creating a subclass is not a solution if there are reasons to recycle the same object over and over again. Using a dict underneath makes it possible to silence errors, but it seems to be a trick rather than the right solution, since this type was designed to map two collections of objects.
What is the correct approach?