Skip to content

Refactor: BaseInvenTreeSetting - #4834

Merged
SchrodingersGat merged 7 commits into
inventree:masterfrom
wolflu05:refactor/settings
May 18, 2023
Merged

SchrodingersGat merged 7 commits into
inventree:masterfrom
wolflu05:refactor/settings

Conversation

@wolflu05

@wolflu05 wolflu05 commented May 16, 2023 •

Copy link
Copy Markdown
Member

This PR tries to add typings for settings and make the common.BaseInvenTreeSetting model more generic. This simplifies the implementation for the #4824 , see #4824 (comment)

Actually first, I planned to only add a get_filters method like the get_kwargs method until I now discovered that something like this was already there onetime and was removed. (See: 5ee9af7). Let me know if you have a better idea to make it more generic.

I tested this and discovered no bugs or issues that something doesnt work or break with this PR. Hopefully tests cover the other half 😄.

@matmair

matmair commented May 16, 2023 •

Copy link
Copy Markdown
Member

@wolflu05 are you sure that the subclass checking is not required for plugin settings?

Edit: It seems there is no coverage on the changed settings code - that would need to be changed

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good in general

Comment thread InvenTree/plugin/models.py Resolved
@wolflu05

Copy link
Copy Markdown
Member Author

are you sure that the subclass checking is not required for plugin settings?

I used project wide code search and checked all method calls individually where I changed something if there is a plugin kwarg. And then looked through the list for plugin= results, changed everything there what I found to call the .plugin_config() function there.

@matmair

matmair commented May 16, 2023

Copy link
Copy Markdown
Member

So we can remove that section entirely?

@wolflu05

Copy link
Copy Markdown
Member Author

What section? The subclass checking in the BaseInventreeSettingClass? Yes. Ideally everything is moved out now and should be implemented in new code like this.

Do you want me to add general tests in this PR? But how do we test an abstract model?

@wolflu05

wolflu05 commented May 17, 2023 •

Copy link
Copy Markdown
Member Author

How do I interpret the coverage report? Especially this line? Should there something be improved? And where is the coverage decrease in this file?

@wolflu05 wolflu05 mentioned this pull request May 17, 2023
@matmair

matmair commented May 17, 2023

Copy link
Copy Markdown
Member

Something seems off with the coverage - I will let it run again

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good but not sure if the uniqueness will work this way

@wolflu05

Copy link
Copy Markdown
Member Author

How do you mean that?

@matmair

matmair commented May 18, 2023

Copy link
Copy Markdown
Member

How do you mean that?

I was worried about removing the kwargs passed to the uniqueness check for user settings, in local testing it seems to work this way though.

@matmair matmair added this to the 0.12.0 milestone May 18, 2023
@matmair

matmair commented May 18, 2023

Copy link
Copy Markdown
Member

@SchrodingersGat 0.12.0 is looking like a big change under the hood - I think especially this one needs a bit of testing in the real world before we release a stable

@SchrodingersGat
SchrodingersGat merged commit cb8ae10 into inventree:master May 18, 2023
@SchrodingersGat

Copy link
Copy Markdown
Member

@wolflu05 thanks for the contribution

@matmair agreed, we won't be pushing out this release immediately!

@wolflu05 wolflu05 mentioned this pull request May 30, 2023
4 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants