- Notifications
You must be signed in to change notification settings - Fork233
-
condensing import statements for brevity: instead of This makes imports more concise and groups related items together |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 4 comments
-
Hey, @YousefAldabbas, thanks again for the issue! This is actually more of a coding style issue, since this change would indeed make the import statements more concise, but would make the code in general more verbose: Current style: # ------- verbose imports -------fromapp.crud.crud_usersimportcrud_usersfromapp.crud.crud_tierimportcrud_tiersfromapp.crud.crud_rate_limitimportcrud_rate_limits# ------- more concise in usage -------db_user=crud_users.get(...)db_tiers=crud_tiers.get_multi(...)... Proposed style: # ------- more concise imports -------fromapp.crudimportcrud_users,crud_tiers,crud_rate_limits# ------- more verbose in usage -------db_user=crud_users.crud_users.get(...)db_tiers=crud_tier.crud_tiers.get_multi(...)... To be honest, I'm not completely sold on any of the options. The advantage of the proposed style would be knowing exactly where the crud_ class comes from, but since it always comes from a crud_ file, I don't think it would do any good. A third possibility would be: # app/crud/crud_all.pyfromcrud_usersimportcrud_usersfromcrud_tierimportcrud_tiers... Importing what's necessary directly from crud_all: # ------- concise imports -------fromapp.crud.crud_allimportcrud_users,crud_tiers,crud_rate_limits# ------- concise in usage -------db_user=crud_users.get(...)db_tiers=crud_tiers.get_multi(...) Pros:
Cons:
I don't think the added complexity is necessary for smaller projects, but maybe it is for larger projects. I'll leave this issue open for some time so you (or someone else) can keep this discussion going until I'm actually certain what to do. |
BetaWas this translation helpful?Give feedback.
All reactions
-
thanks for your patient, to
|
BetaWas this translation helpful?Give feedback.
All reactions
-
True, didn't think about it, but is definitely better than creating a |
BetaWas this translation helpful?Give feedback.
All reactions
-
I'll convert it to a discussion because it may be useful for people who choose this style, but I think it's better leaving the decision to who's using the boilerplate. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
This discussion was converted from issue #42 on November 14, 2023 20:48.