Skip to content

23 configuration assistance#35

Open
JaszczurGra wants to merge 10 commits intomainfrom
23-configuration-assistance
Open

23 configuration assistance#35
JaszczurGra wants to merge 10 commits intomainfrom
23-configuration-assistance

Conversation

@JaszczurGra
Copy link
Copy Markdown
Collaborator

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

 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
@JaszczurGra JaszczurGra linked an issue Feb 2, 2025 that may be closed by this pull request
Copy link
Copy Markdown
Owner

@Dawid64 Dawid64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

#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):
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does putting a _open_file function count as nested and should be moved outside of the decorator?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also minor change, you may avoid Polish names for integrity

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where were polish names?

@JaszczurGra
Copy link
Copy Markdown
Collaborator Author

JaszczurGra commented Feb 9, 2025

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

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.
(Could add validate typehint ass the decorator before wraps to first check the args coming from the function call and then when returning function for configuration typehint checking if wanted)

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?


match Path(path).suffix:
case '.yaml' | '.yml':
try:
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@JaszczurGra JaszczurGra requested a review from Dawid64 February 11, 2025 00:25
Copy link
Copy Markdown
Owner

@Dawid64 Dawid64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@JaszczurGra
Copy link
Copy Markdown
Collaborator Author

JaszczurGra commented Mar 26, 2025

Looks good , but one more personon needs to approve

@JaszczurGra JaszczurGra requested a review from adamtms March 26, 2025 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration assistance

2 participants