F841: local variable is assigned to but never used

This commit is contained in:
Andre Miras 2020-04-13 17:26:17 +02:00
parent 58774d8aac
commit 5f35e8b409
5 changed files with 9 additions and 13 deletions

View file

@ -374,13 +374,10 @@ class TargetAndroid(Target):
self.buildozer.info('Android SDK is missing, downloading') self.buildozer.info('Android SDK is missing, downloading')
if platform in ('win32', 'cygwin'): if platform in ('win32', 'cygwin'):
archive = 'sdk-tools-windows-{}.zip'.format(DEFAULT_SDK_TAG) archive = 'sdk-tools-windows-{}.zip'.format(DEFAULT_SDK_TAG)
unpacked = 'android-sdk-windows'
elif platform in ('darwin', ): elif platform in ('darwin', ):
archive = 'sdk-tools-darwin-{}.zip'.format(DEFAULT_SDK_TAG) archive = 'sdk-tools-darwin-{}.zip'.format(DEFAULT_SDK_TAG)
unpacked = 'android-sdk-macosx'
elif platform.startswith('linux'): elif platform.startswith('linux'):
archive = 'sdk-tools-linux-{}.zip'.format(DEFAULT_SDK_TAG) archive = 'sdk-tools-linux-{}.zip'.format(DEFAULT_SDK_TAG)
unpacked = 'android-sdk-linux'
else: else:
raise SystemError('Unsupported platform: {0}'.format(platform)) raise SystemError('Unsupported platform: {0}'.format(platform))
@ -784,7 +781,6 @@ class TargetAndroid(Target):
if local_recipes: if local_recipes:
options.append('--local-recipes') options.append('--local-recipes')
options.append(local_recipes) options.append(local_recipes)
config = self.buildozer.config
self._p4a( self._p4a(
("create --dist_name={} --bootstrap={} --requirements={} " ("create --dist_name={} --bootstrap={} --requirements={} "
"--arch {} {}").format( "--arch {} {}").format(
@ -811,7 +807,6 @@ class TargetAndroid(Target):
old_dist_dir = join(self._build_dir, 'dists', dist_name) old_dist_dir = join(self._build_dir, 'dists', dist_name)
if exists(old_dist_dir): if exists(old_dist_dir):
return old_dist_dir return old_dist_dir
matching_dirs = glob.glob(join(self._build_dir, 'dist', '{}*'.format(dist_name)))
# If no directory has been found yet, our dist probably # If no directory has been found yet, our dist probably
# doesn't exist yet, so use the expected name # doesn't exist yet, so use the expected name

View file

@ -114,7 +114,6 @@ class TargetOSX(Target):
bc = self.buildozer.config bc = self.buildozer.config
bcg = bc.get bcg = bc.get
bcgl = bc.getlist
package_name = bcg('app', 'package.name') package_name = bcg('app', 'package.name')
domain = bcg('app', 'package.domain') domain = bcg('app', 'package.domain')
title = bcg('app', 'title') title = bcg('app', 'title')

View file

@ -88,7 +88,7 @@ class TestTargetAndroid:
def test_init_positional_buildozer(self): def test_init_positional_buildozer(self):
"""Positional `buildozer` argument is required.""" """Positional `buildozer` argument is required."""
with pytest.raises(TypeError) as ex_info: with pytest.raises(TypeError) as ex_info:
target_android = TargetAndroid() TargetAndroid()
assert ex_info.value.args == ( assert ex_info.value.args == (
"__init__() missing 1 required positional argument: 'buildozer'", "__init__() missing 1 required positional argument: 'buildozer'",
) )

View file

@ -48,8 +48,8 @@ class TestBuildozer(unittest.TestCase):
""" """
with open(filepath) as f: with open(filepath) as f:
file_content = f.read() file_content = f.read()
file_content = re.sub(pattern, replace, file_content)
with open(filepath, 'w') as f: with open(filepath, 'w') as f:
file_content = re.sub(pattern, replace, file_content)
f.write(file_content) f.write(file_content)
@classmethod @classmethod
@ -61,6 +61,7 @@ class TestBuildozer(unittest.TestCase):
replace = 'log_level = {}'.format(log_level) replace = 'log_level = {}'.format(log_level)
cls.file_re_sub(specfilename, pattern, replace) cls.file_re_sub(specfilename, pattern, replace)
buildozer = Buildozer(specfilename) buildozer = Buildozer(specfilename)
assert buildozer.log_level == log_level
def test_buildozer_base(self): def test_buildozer_base(self):
""" """
@ -155,15 +156,17 @@ class TestBuildozer(unittest.TestCase):
# Mock first run # Mock first run
with mock.patch('buildozer.Buildozer.download') as download, \ with mock.patch('buildozer.Buildozer.download') as download, \
mock.patch('buildozer.Buildozer.file_extract') as extract_file, \ mock.patch('buildozer.Buildozer.file_extract') as m_file_extract, \
mock.patch('os.makedirs'): mock.patch('os.makedirs'):
ant_path = target._install_apache_ant() ant_path = target._install_apache_ant()
assert ant_path == my_ant_path assert m_file_extract.call_args_list == [mock.call(mock.ANY, cwd='/my/ant/path')]
assert ant_path == my_ant_path
assert download.call_args_list == [
mock.call("http://archive.apache.org/dist/ant/binaries/", mock.ANY, cwd=my_ant_path)]
# Mock ant already installed # Mock ant already installed
with mock.patch.object(Buildozer, 'file_exists', return_value=True): with mock.patch.object(Buildozer, 'file_exists', return_value=True):
ant_path = target._install_apache_ant() ant_path = target._install_apache_ant()
assert ant_path == my_ant_path assert ant_path == my_ant_path
def test_cmd_unicode_decode(self): def test_cmd_unicode_decode(self):
""" """

View file

@ -38,7 +38,6 @@ ignore =
E731, # do not assign a lambda expression, use a def E731, # do not assign a lambda expression, use a def
F401, # imported but unused F401, # imported but unused
F821, # undefined name F821, # undefined name
F841, # local variable is assigned to but never used
W503, # line break before binary operator W503, # line break before binary operator
W504, # line break after binary operator W504, # line break after binary operator
W605 # invalid escape sequence W605 # invalid escape sequence