Skip to content

Commit

Permalink
Merge pull request kivy#1066 from AndreMiras/feature/linter_F841
Browse files Browse the repository at this point in the history
F841: local variable is assigned to but never used
  • Loading branch information
AndreMiras authored Apr 13, 2020
2 parents 422f951 + 5f35e8b commit d3361bb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
5 changes: 0 additions & 5 deletions buildozer/targets/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,10 @@ def _install_android_sdk(self):
self.buildozer.info('Android SDK is missing, downloading')
if platform in ('win32', 'cygwin'):
archive = 'sdk-tools-windows-{}.zip'.format(DEFAULT_SDK_TAG)
unpacked = 'android-sdk-windows'
elif platform in ('darwin', ):
archive = 'sdk-tools-darwin-{}.zip'.format(DEFAULT_SDK_TAG)
unpacked = 'android-sdk-macosx'
elif platform.startswith('linux'):
archive = 'sdk-tools-linux-{}.zip'.format(DEFAULT_SDK_TAG)
unpacked = 'android-sdk-linux'
else:
raise SystemError('Unsupported platform: {0}'.format(platform))

Expand Down Expand Up @@ -784,7 +781,6 @@ def compile_platform(self):
if local_recipes:
options.append('--local-recipes')
options.append(local_recipes)
config = self.buildozer.config
self._p4a(
("create --dist_name={} --bootstrap={} --requirements={} "
"--arch {} {}").format(
Expand All @@ -811,7 +807,6 @@ def get_dist_dir(self, dist_name, arch):
old_dist_dir = join(self._build_dir, 'dists', dist_name)
if exists(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
# doesn't exist yet, so use the expected name
Expand Down
1 change: 0 additions & 1 deletion buildozer/targets/osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def build_package(self):

bc = self.buildozer.config
bcg = bc.get
bcgl = bc.getlist
package_name = bcg('app', 'package.name')
domain = bcg('app', 'package.domain')
title = bcg('app', 'title')
Expand Down
2 changes: 1 addition & 1 deletion tests/targets/test_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_init(self):
def test_init_positional_buildozer(self):
"""Positional `buildozer` argument is required."""
with pytest.raises(TypeError) as ex_info:
target_android = TargetAndroid()
TargetAndroid()
assert ex_info.value.args == (
"__init__() missing 1 required positional argument: 'buildozer'",
)
Expand Down
13 changes: 8 additions & 5 deletions tests/test_buildozer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def file_re_sub(filepath, pattern, replace):
"""
with open(filepath) as f:
file_content = f.read()
file_content = re.sub(pattern, replace, file_content)
with open(filepath, 'w') as f:
file_content = re.sub(pattern, replace, file_content)
f.write(file_content)

@classmethod
Expand All @@ -61,6 +61,7 @@ def set_specfile_log_level(cls, specfilename, log_level):
replace = 'log_level = {}'.format(log_level)
cls.file_re_sub(specfilename, pattern, replace)
buildozer = Buildozer(specfilename)
assert buildozer.log_level == log_level

def test_buildozer_base(self):
"""
Expand Down Expand Up @@ -155,15 +156,17 @@ def test_android_ant_path(self):

# Mock first run
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'):
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
with mock.patch.object(Buildozer, 'file_exists', return_value=True):
ant_path = target._install_apache_ant()
assert ant_path == my_ant_path
assert ant_path == my_ant_path

def test_cmd_unicode_decode(self):
"""
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ ignore =
E731, # do not assign a lambda expression, use a def
F401, # imported but unused
F821, # undefined name
F841, # local variable is assigned to but never used
W503, # line break before binary operator
W504, # line break after binary operator
W605 # invalid escape sequence

0 comments on commit d3361bb

Please sign in to comment.