Skip to content

Commit 00719ae

Browse files
committed
Fix some code quality and bug-risk issues
1 parent 47c9c33 commit 00719ae

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

.deepsource.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version = 1
2+
3+
test_patterns = ["tests/**"]
4+
5+
exclude_patterns = ["testapps/**"]
6+
7+
[[analyzers]]
8+
name = "python"
9+
enabled = true
10+
11+
[analyzers.meta]
12+
runtime_version = "3.x.x"

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22
include LICENSE README.md
3+
include *.toml
34

45
recursive-include doc *
56
prune doc/build

pythonforandroid/bootstrap.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def get_usable_bootstraps_for_recipes(cls, recipes, ctx):
195195
# Check if the bootstap's dependencies have an internal conflict:
196196
for recipe in possible_dependencies:
197197
recipe = Recipe.get_recipe(recipe, ctx)
198-
if any([conflict in recipes for conflict in recipe.conflicts]):
198+
if any(conflict in recipes for conflict in recipe.conflicts):
199199
ok = False
200200
break
201201
# Check if bootstrap's dependencies conflict with chosen
@@ -207,8 +207,8 @@ def get_usable_bootstraps_for_recipes(cls, recipes, ctx):
207207
conflicts = []
208208
else:
209209
conflicts = recipe.conflicts
210-
if any([conflict in possible_dependencies
211-
for conflict in conflicts]):
210+
if any(conflict in possible_dependencies
211+
for conflict in conflicts):
212212
ok = False
213213
break
214214
if ok and bs not in acceptable_bootstraps:

pythonforandroid/build.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def prepare_build_environment(self,
267267
d.endswith(('.bz2', '.gz'))]
268268
if possible_dirs:
269269
info('Found possible SDK dirs in buildozer dir: {}'.format(
270-
', '.join([d.split(os.sep)[-1] for d in possible_dirs])))
270+
', '.join(d.split(os.sep)[-1] for d in possible_dirs)))
271271
info('Will attempt to use SDK at {}'.format(possible_dirs[0]))
272272
warning('This SDK lookup is intended for debug only, if you '
273273
'use python-for-android much you should probably '
@@ -328,7 +328,7 @@ def prepare_build_environment(self,
328328
'~', '.buildozer', 'android', 'platform', 'android-ndk-r*')))
329329
if possible_dirs:
330330
info('Found possible NDK dirs in buildozer dir: {}'.format(
331-
', '.join([d.split(os.sep)[-1] for d in possible_dirs])))
331+
', '.join(d.split(os.sep)[-1] for d in possible_dirs)))
332332
info('Will attempt to use NDK at {}'.format(possible_dirs[0]))
333333
warning('This NDK lookup is intended for debug only, if you '
334334
'use python-for-android much you should probably '
@@ -479,7 +479,7 @@ def set_archs(self, arch_names):
479479
if not self.archs:
480480
raise BuildInterruptingException('Asked to compile for no Archs, so failing.')
481481
info('Will compile for the following archs: {}'.format(
482-
', '.join([arch.arch for arch in self.archs])))
482+
', '.join(arch.arch for arch in self.archs)))
483483

484484
def prepare_bootstrap(self, bs):
485485
bs.ctx = self
@@ -894,7 +894,9 @@ def biglink(ctx, arch):
894894
env=env)
895895

896896

897-
def biglink_function(soname, objs_paths, extra_link_dirs=[], env=None):
897+
def biglink_function(soname, objs_paths, extra_link_dirs=None, env=None):
898+
if extra_link_dirs is None:
899+
extra_link_dirs = []
898900
print('objs_paths are', objs_paths)
899901
sofiles = []
900902

@@ -941,7 +943,9 @@ def biglink_function(soname, objs_paths, extra_link_dirs=[], env=None):
941943
shprint(cc, '-shared', '-O3', '-o', soname, *unique_args, _env=env)
942944

943945

944-
def copylibs_function(soname, objs_paths, extra_link_dirs=[], env=None):
946+
def copylibs_function(soname, objs_paths, extra_link_dirs=None, env=None):
947+
if extra_link_dirs is None:
948+
extra_link_dirs = []
945949
print('objs_paths are', objs_paths)
946950

947951
re_needso = re.compile(r'^.*\(NEEDED\)\s+Shared library: \[lib(.*)\.so\]\s*$')

pythonforandroid/recipes/matplotlib/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def download_web_backend_dependencies(self, arch):
8585
jquery_sha = (
8686
'f8233674366ab36b2c34c577ec77a3d70cac75d2e387d8587f3836345c0f624d'
8787
)
88-
url = f'https://jqueryui.com/resources/download/jquery-ui-1.12.1.zip'
88+
url = "https://jqueryui.com/resources/download/jquery-ui-1.12.1.zip"
8989
target_file = join(env['XDG_CACHE_HOME'], 'matplotlib', jquery_sha)
9090

9191
info_notify(f'Will download into {env["XDG_CACHE_HOME"]}')

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
def recursively_include(results, directory, patterns):
3535
for root, subfolders, files in walk(directory):
3636
for fn in files:
37-
if not any([glob.fnmatch.fnmatch(fn, pattern) for pattern in patterns]):
37+
if not any(glob.fnmatch.fnmatch(fn, pattern) for pattern in patterns):
3838
continue
3939
filename = join(root, fn)
4040
directory = 'pythonforandroid'

0 commit comments

Comments
 (0)