You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The _build_prepared code is overly complicated, and should be refactored.
The Buildozer instance wants to make sure if doesn't prepare a build twice for the same target.
In the current implementation, it attaches its own attribute, _build_prepared to the Target instance. It sets it to True when it has finished prepare_for_build, but the value is ignored. It checks for its existence at the beginning of prepare_for_build and build.
[Note: This triggers style-checkers that don't like attributes with leading underscores being accessed from outside the class.]
Meanwhile, the osx target has a check_build_prepared(), which has four weird behaviours:
It is only called after prepare_for_build(), so we know the build has been prepared. It appears to be a pointless check.
It is only called in the case of a debug build, not a release build, which is an unexplained inconsistency.
Despite its name, it doesn't check the value of _build_prepared. Instead, it sets the value, thus (re)declaring it built.
It sets the value to False. The value is never used, so this is functionally equivalent to setting it to True, but it isn't clear if some difference was intended.
[Note: This triggers style-checkers that don't like attributes being set in methods that aren't declared in the __init__ methods]
My recommendation:
In the base class, Target.__init__(), add an instance attribute called is_build_prepared` and set it to False. (No leading underscore - it is a public attribute,)
Modify the Buildozer class to assume its existence and use it as a Boolean.
Remove check_build_prepare() from osx.
[I am raising this as a bug report rather than a simple PR, because I am aware I haven't figured out why the osx target is behaving this way, and that can make refactoring more dangerous.]
The text was updated successfully, but these errors were encountered:
Versions
Description
The
_build_prepared
code is overly complicated, and should be refactored.The Buildozer instance wants to make sure if doesn't prepare a build twice for the same target.
In the current implementation, it attaches its own attribute,
_build_prepared
to the Target instance. It sets it to True when it has finishedprepare_for_build
, but the value is ignored. It checks for its existence at the beginning ofprepare_for_build
andbuild
.[Note: This triggers style-checkers that don't like attributes with leading underscores being accessed from outside the class.]
Meanwhile, the osx target has a
check_build_prepared()
, which has four weird behaviours:prepare_for_build()
, so we know the build has been prepared. It appears to be a pointless check._build_prepared
. Instead, it sets the value, thus (re)declaring it built.[Note: This triggers style-checkers that don't like attributes being set in methods that aren't declared in the
__init__
methods]My recommendation:
Target.__init__(), add an instance attribute called
is_build_prepared` and set it to False. (No leading underscore - it is a public attribute,)Buildozer
class to assume its existence and use it as a Boolean.check_build_prepare()
from osx.[I am raising this as a bug report rather than a simple PR, because I am aware I haven't figured out why the osx target is behaving this way, and that can make refactoring more dangerous.]
The text was updated successfully, but these errors were encountered: