feat: expose classmethod to build tortoise config#2162
feat: expose classmethod to build tortoise config#2162waketzheng wants to merge 6 commits intotortoise:developfrom
Conversation
|
@waketzheng this PR has many changes that are not related to the PR title and description. Maybe you should break them into multiple PRs? |
|
@waketzheng this PR still seems to have unrelated changes. We have this PR to add pre-commit, and this PR for Starlette v1 support. These changes can probably be removed from this PR |
@seladb No need to do that. I expected this PR to be reviewed after the previous one merged, so I explicitly mentioned that it’s |
@waketzheng is there a reason to open these changes as stacked PRs? It looks like these are separate changes that can each have their own PR based on |
7e95e57 to
b1e1093
Compare
|
Yes, if the changes in the stacked PRs depend on each other, otherwise there shouldn't be merge conflicts. Here it looks like the actual commit related to this PR doesn't depend on the changes in the other PR. What am I missing here? 🤔 |
You forgot that I need the pre-commit config to enforce code style. |
I'm not sure why pre-commit is needed for this PR, but anyway - the pre-commit PR was merged so this PR is simpler now 🙂 |
seladb
left a comment
There was a problem hiding this comment.
Please see one comment, otherwise LGTM
| return cls.from_dict(config_dict) | ||
|
|
||
| @classmethod | ||
| def _get_config_from_config_file(cls, config_file: str) -> TortoiseConfig: |
There was a problem hiding this comment.
Maybe we can make it a public method instead of private/protected?
There was a problem hiding this comment.
Maybe we can make it a public method instead of private/protected?
If it to be a public method, should generating config from db_url/modules also be public? For example:
230 else:
231 return cls.generate_config(db_url, modules)
232
233 @classmethod
234 def generate_config(
235 cls, db_url: str, modules: dict[str, Iterable[str | ModuleType]]
236 ) -> TortoiseConfig:
237 from tortoise.backends.base.config_generator import generate_config
238
239 config_dict = generate_config(db_url, app_modules=modules)
240 return cls.from_dict(config_dict)
241
242 @classmethod
243 def get_config_from_config_file(cls, config_file: str) -> TortoiseConfig:


Description
initfunction of tortoise.context.Context is too longMotivation and Context
Base on #2159
This function has too many lines; shorten it.
How Has This Been Tested?
Checklist: