tuttle-dev / tuttle

🪰 Tuttle - time and money management for freelancers
GNU General Public License v3.0
62 stars 12 forks source link

Code style: Consistent import style #131

Closed clstaudt closed 1 year ago

clstaudt commented 1 year ago

A)

import flet

flet.Text(....)

B)

from flet import (
    Text,
)
clstaudt commented 1 year ago

@vlad-ed-git Which style do you prefer?

In any case, pick one and keep it consistent throughout the project.

Don't do this, it's silly:

import flet as ft

I know the flet developers do it but I think it's a silly trend, saving two letters and risking even more package name collisions than we already have in the Python world.

vlad-ed-git commented 1 year ago

I prefer importing all components at the top . I only started refactoring because you prefer fewer import lines. L And I think ft for this is far better than using flet ... ft.Column , ft.Card ... is far better to my eyes than flet.Column, flet.Card . But these are all just preferences , there's isn't a science to it. We just pick one and use that.

On Wednesday, January 11, 2023, Christian Staudt @.***> wrote:

Which style do you prefer?

In any case, pick one and keep it consistent throughout the project.

Don't do this, it's silly:

import flet as ft

I know the flet developers do it but I think it's a silly trend, saving two letters and risking even more package name collisions than we already have in the Python world.

— Reply to this email directly, view it on GitHub https://github.com/tuttle-dev/tuttle/issues/131#issuecomment-1378820243, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJGBW63OBLOX6SEAOEODMX3WR26GVANCNFSM6AAAAAATYC23RI . You are receiving this because you were assigned.Message ID: @.***>

clstaudt commented 1 year ago

Let's go for style B then.

It's not just about the amount of lines, it's about understandable code.

My thinking: When I am writing a UI view, then the components from flet are "first class citizens", I import them directly. It's clear where these things come from when I write a flet app. Other things that I need I tend to import indirectly because it's not immediately clear where they are from.

vlad-ed-git commented 1 year ago

Style B is import Flet and use flet.control?

On Wednesday, January 11, 2023, Christian Staudt @.***> wrote:

Let's go for style B then.

It's not just about the amount of lines, it's about understandable code.

My thinking: When I am writing a UI view, then the components from flet are "first class citizens", I import them directly. It's clear where these things come from when I write a flet app. Other things that I need I tend to import indirectly because it's not immediately clear where they are from.

— Reply to this email directly, view it on GitHub https://github.com/tuttle-dev/tuttle/issues/131#issuecomment-1378885826, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJGBW67O5VSSCJ6A6NXSS53WR3DA3ANCNFSM6AAAAAATYC23RI . You are receiving this because you were mentioned.Message ID: @.***>

clstaudt commented 1 year ago
from flet import (
    Text,
    UserControl,
    ElevatedButton,
)

a_button = ElevatedButton()
vlad-ed-git commented 1 year ago

Okay

On Wednesday, January 11, 2023, Christian Staudt @.***> wrote:

from flet import ( Text, UserControl, ElevatedButton, ) a_button = ElevatedButton()

— Reply to this email directly, view it on GitHub https://github.com/tuttle-dev/tuttle/issues/131#issuecomment-1378891104, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJGBW67WX7TLKYZ3575QPFTWR3DMJANCNFSM6AAAAAATYC23RI . You are receiving this because you were mentioned.Message ID: @.***>

vlad-ed-git commented 1 year ago

TODOs