Conversation
typ to zapisuje sie jako <class, 'int'> a nie jako int i potem tego nie czyta albo teraz jest zrobione ze zapisuje sie jako 'int' i tez nie dziala
Dawid64
left a comment
There was a problem hiding this comment.
Reformat code - do not use hadouken indentation.
Why is there a type hint validation? I believe this is already implemented in other decorator (type hints_validation) or something like that
decorify/configuration.py
Outdated
| #setting to args | ||
| if name in config: | ||
|
|
||
| if isinstance(config[name], (int,float) if info.annotation == float else info.annotation if info.annotation != inspect._empty else object): |
There was a problem hiding this comment.
I also like creating one liners, but nesting if statements in such a way makes it's harder to read.
Also
if condition:
logic()
else:
raise()is terrible practice, you should avoid it at all cost, try using
if not condition:
raise()
logic()it makes logic not nested and it avoids hadouken indentation
There was a problem hiding this comment.
So does putting a _open_file function count as nested and should be moved outside of the decorator?
There was a problem hiding this comment.
Overall code should not be nested, and it's unrecommended to make lines with size greater than 100, in my opinion 140 should be hard limit, but it's rather personal, I recommend using formatter, to avoid such problems, also avoid nesting. Logic may work fine, but it's unreadable. Feel free to take a look at: https://www.youtube.com/watch?v=CFRhGnuXG-4
There was a problem hiding this comment.
Also minor change, you may avoid Polish names for integrity
There was a problem hiding this comment.
Where were polish names?
So I wanted to have better logging so that it tells you if the wrong typehint was in the config or in the function call. As well as passing the config attributes as args if they don't have default value in the function definition and not as kwargs always but idk if it's necessary? |
decorify/configuration.py
Outdated
|
|
||
| match Path(path).suffix: | ||
| case '.yaml' | '.yml': | ||
| try: |
There was a problem hiding this comment.
imports could be added at the beginning of the file (run only initilization and store the import success value for yaml as constant bool), that would make the code less nested as well as could reduce the runtime if opening yaml file would be required multiple times
Dawid64
left a comment
There was a problem hiding this comment.
I added few changes, with them looks all good to me, if you don't agree with them feel free to git reset --hard HEAD~3
|
Looks good , but one more personon needs to approve |
Test's don't include teseting if the version is lower 3.11+ for toml imports and require yaml installed idk how to add it temporarily