Skip to content

Fix some code quality and bug-risk issues #2141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version = 1

test_patterns = ["tests/**"]

exclude_patterns = ["testapps/**"]

[[analyzers]]
name = "python"
enabled = true

[analyzers.meta]
runtime_version = "3.x.x"
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

include LICENSE README.md
include *.toml

recursive-include doc *
prune doc/build
Expand Down
6 changes: 3 additions & 3 deletions pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def get_usable_bootstraps_for_recipes(cls, recipes, ctx):
# Check if the bootstap's dependencies have an internal conflict:
for recipe in possible_dependencies:
recipe = Recipe.get_recipe(recipe, ctx)
if any([conflict in recipes for conflict in recipe.conflicts]):
if any(conflict in recipes for conflict in recipe.conflicts):
ok = False
break
# Check if bootstrap's dependencies conflict with chosen
Expand All @@ -207,8 +207,8 @@ def get_usable_bootstraps_for_recipes(cls, recipes, ctx):
conflicts = []
else:
conflicts = recipe.conflicts
if any([conflict in possible_dependencies
for conflict in conflicts]):
if any(conflict in possible_dependencies
for conflict in conflicts):
ok = False
break
if ok and bs not in acceptable_bootstraps:
Expand Down
14 changes: 9 additions & 5 deletions pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def prepare_build_environment(self,
d.endswith(('.bz2', '.gz'))]
if possible_dirs:
info('Found possible SDK dirs in buildozer dir: {}'.format(
', '.join([d.split(os.sep)[-1] for d in possible_dirs])))
', '.join(d.split(os.sep)[-1] for d in possible_dirs)))
info('Will attempt to use SDK at {}'.format(possible_dirs[0]))
warning('This SDK lookup is intended for debug only, if you '
'use python-for-android much you should probably '
Expand Down Expand Up @@ -328,7 +328,7 @@ def prepare_build_environment(self,
'~', '.buildozer', 'android', 'platform', 'android-ndk-r*')))
if possible_dirs:
info('Found possible NDK dirs in buildozer dir: {}'.format(
', '.join([d.split(os.sep)[-1] for d in possible_dirs])))
', '.join(d.split(os.sep)[-1] for d in possible_dirs)))
info('Will attempt to use NDK at {}'.format(possible_dirs[0]))
warning('This NDK lookup is intended for debug only, if you '
'use python-for-android much you should probably '
Expand Down Expand Up @@ -479,7 +479,7 @@ def set_archs(self, arch_names):
if not self.archs:
raise BuildInterruptingException('Asked to compile for no Archs, so failing.')
info('Will compile for the following archs: {}'.format(
', '.join([arch.arch for arch in self.archs])))
', '.join(arch.arch for arch in self.archs)))

def prepare_bootstrap(self, bs):
bs.ctx = self
Expand Down Expand Up @@ -894,7 +894,9 @@ def biglink(ctx, arch):
env=env)


def biglink_function(soname, objs_paths, extra_link_dirs=[], env=None):
def biglink_function(soname, objs_paths, extra_link_dirs=None, env=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Special thanks for this change :) default mutable argument gotcha 👍

if extra_link_dirs is None:
extra_link_dirs = []
print('objs_paths are', objs_paths)
sofiles = []

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


def copylibs_function(soname, objs_paths, extra_link_dirs=[], env=None):
def copylibs_function(soname, objs_paths, extra_link_dirs=None, env=None):
if extra_link_dirs is None:
extra_link_dirs = []
print('objs_paths are', objs_paths)

re_needso = re.compile(r'^.*\(NEEDED\)\s+Shared library: \[lib(.*)\.so\]\s*$')
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def download_web_backend_dependencies(self, arch):
jquery_sha = (
'f8233674366ab36b2c34c577ec77a3d70cac75d2e387d8587f3836345c0f624d'
)
url = f'https://jqueryui.com/resources/download/jquery-ui-1.12.1.zip'
url = "https://jqueryui.com/resources/download/jquery-ui-1.12.1.zip"
target_file = join(env['XDG_CACHE_HOME'], 'matplotlib', jquery_sha)

info_notify(f'Will download into {env["XDG_CACHE_HOME"]}')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
def recursively_include(results, directory, patterns):
for root, subfolders, files in walk(directory):
for fn in files:
if not any([glob.fnmatch.fnmatch(fn, pattern) for pattern in patterns]):
if not any(glob.fnmatch.fnmatch(fn, pattern) for pattern in patterns):
continue
filename = join(root, fn)
directory = 'pythonforandroid'
Expand Down