Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 162cf12

Browse files
committed
cleaning up OptionalBackendPackage a tiny bit
- check for `if config is not None` before the try/except/pass adds nothing, just makes it less readable - much clearer to handle of the default value of the `install` variable with the base class and not nested in a try/except of the `get_config` method (and even duplicated outside of the try/except) - the `force` attribute (only used for BackendAgg right now it seems) should also have a more prominent default state in the base class rather than in just one subclass
1 parent f453421 commit 162cf12

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

setupext.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -455,18 +455,17 @@ def check(self):
455455

456456
class OptionalBackendPackage(SetupPackage):
457457
optional = True
458+
force = False
459+
install = 'auto'
458460

459461
def get_config(self):
460-
install = 'auto'
461-
if config is not None:
462-
try:
463-
install = config.getboolean(
464-
'gui_support', self.name)
465-
except:
466-
install = 'auto'
467-
if install is True:
462+
try:
463+
self.install = config.getboolean('gui_support', self.name)
464+
except:
465+
pass
466+
if self.install is True:
468467
self.optional = False
469-
return install
468+
return self.install
470469

471470

472471
class Platform(SetupPackage):
@@ -981,7 +980,6 @@ def get_install_requires(self):
981980

982981
class BackendAgg(OptionalBackendPackage):
983982
name = "agg"
984-
force = False
985983

986984
def check(self):
987985
# The Agg backend extension needs to be built even

0 commit comments

Comments
 (0)