Skip to content

Commit c676b0b

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

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

.deepsource.toml

Lines changed: 12 additions & 0 deletions
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"

pythonforandroid/archs.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,10 @@ def get_env(self, with_flags_in_cc=True):
143143
env['LDFLAGS'] = (
144144
' '
145145
+ " ".join(
146-
[
147-
"-L'"
146+
"-L'"
148147
+ l.replace("'", "'\"'\"'")
149148
+ "'" # no shlex.quote in py2
150149
for l in self.extra_global_link_paths
151-
]
152150
)
153151
+ ' ' + ' '.join(self.common_ldflags).format(
154152
ctx_libs_dir=self.ctx.get_libs_dir(self.arch)

pythonforandroid/bootstrap.py

Lines changed: 3 additions & 3 deletions
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

Lines changed: 9 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy