From 47fbce1feb49828c300acca5933be0ca970a33f5 Mon Sep 17 00:00:00 2001 From: Mirko Galimberti Date: Fri, 8 Dec 2023 15:36:36 +0100 Subject: [PATCH] Fix pep8 failures, and apply black formatting where applicable. (#788) --- docs/source/conf.py | 7 ++++++- plyer/platforms/android/filechooser.py | 16 ++++++++++------ plyer/platforms/linux/filechooser.py | 6 +++--- plyer/platforms/macosx/filechooser.py | 2 +- plyer/platforms/win/filechooser.py | 2 +- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index f898c84c..fcda58aa 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -56,6 +56,7 @@ # built documents. # + # Lookup the version from the pyjnius module, without installing it # since readthedocs.org may have issue to install it. # Read the version from the __init__.py file, without importing it. @@ -64,10 +65,14 @@ def get_version(): os.path.join(os.path.abspath("../.."), "plyer", "__init__.py") ) as fp: for line in fp: - m = re.search(r'^\s*__version__\s*=\s*([\'"])([^\'"]+)\1\s*$', line) + m = re.search( + r'^\s*__version__\s*=\s*([\'"])([^\'"]+)\1\s*$', + line, + ) if m: return m.group(2) + # The short X.Y version. version = get_version() # The full version, including alpha/beta/rc tags. diff --git a/plyer/platforms/android/filechooser.py b/plyer/platforms/android/filechooser.py index bcc45ed3..b8c943cf 100644 --- a/plyer/platforms/android/filechooser.py +++ b/plyer/platforms/android/filechooser.py @@ -143,9 +143,11 @@ def _open_file(self, **kwargs): # create Intent for opening file_intent = Intent(Intent.ACTION_GET_CONTENT) - if not self.selected_mime_type or \ - type(self.selected_mime_type) != str or \ - self.selected_mime_type not in self.mime_type: + if ( + not self.selected_mime_type + or not isinstance(self.selected_mime_type, str) + or self.selected_mime_type not in self.mime_type + ): file_intent.setType("*/*") else: file_intent.setType(self.mime_type[self.selected_mime_type]) @@ -176,9 +178,11 @@ def _save_file(self, **kwargs): kwargs.pop("filters")[0] if "filters" in kwargs else "" file_intent = Intent(Intent.ACTION_CREATE_DOCUMENT) - if not self.selected_mime_type or \ - type(self.selected_mime_type) != str or \ - self.selected_mime_type not in self.mime_type: + if ( + not self.selected_mime_type + or not isinstance(self.selected_mime_type, str) + or self.selected_mime_type not in self.mime_type + ): file_intent.setType("*/*") else: file_intent.setType(self.mime_type[self.selected_mime_type]) diff --git a/plyer/platforms/linux/filechooser.py b/plyer/platforms/linux/filechooser.py index a2c0f552..e4ac8570 100644 --- a/plyer/platforms/linux/filechooser.py +++ b/plyer/platforms/linux/filechooser.py @@ -122,7 +122,7 @@ def _gen_cmdline(self): if self.icon: cmdline += ["--window-icon", self.icon] for f in self.filters: - if type(f) == str: + if isinstance(f, str): cmdline += ["--file-filter", f] else: cmdline += [ @@ -150,7 +150,7 @@ def _gen_cmdline(self): filt = [] for f in self.filters: - if type(f) == str: + if isinstance(f, str): filt += [f] else: filt += list(f[1:]) @@ -215,7 +215,7 @@ def _gen_cmdline(self): if self.icon: cmdline += ["--window-icon", self.icon] for f in self.filters: - if type(f) == str: + if isinstance(f, str): cmdline += ["--file-filter", f] else: cmdline += [ diff --git a/plyer/platforms/macosx/filechooser.py b/plyer/platforms/macosx/filechooser.py index 85fb91c7..38ab99d0 100644 --- a/plyer/platforms/macosx/filechooser.py +++ b/plyer/platforms/macosx/filechooser.py @@ -80,7 +80,7 @@ def run(self): if self.filters: filthies = [] for f in self.filters: - if type(f) == str: + if isinstance(f, str): f = (None, f) for s in f[1:]: if not self.use_extensions: diff --git a/plyer/platforms/win/filechooser.py b/plyer/platforms/win/filechooser.py index d61fdc11..8a26fe3c 100644 --- a/plyer/platforms/win/filechooser.py +++ b/plyer/platforms/win/filechooser.py @@ -84,7 +84,7 @@ def run(self): # e.g. open_file(filters=['*.txt', '*.py']) filters = "" for f in self.filters: - if type(f) == str: + if isinstance(f, str): filters += (f + "\x00") * 2 else: filters += f[0] + "\x00" + ";".join(f[1:]) + "\x00"