public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [flatpaks/flatpak-runtime] f45: Add a .flake8 to suppress warnings and fix up other warnings
@ 2026-09-11 14:42 Owen W. Taylor
0 siblings, 0 replies; only message in thread
From: Owen W. Taylor @ 2026-09-11 14:42 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : flatpaks/flatpak-runtime
Branch : f45
Commit : bbb89f6b785133ef5d57c08a6d09d730c631d069
Author : Owen W. Taylor <otaylor@fishsoup.net>
Date : 2026-03-02T20:29:45-05:00
Stats : +105/-65 in 6 file(s)
URL : https://src.fedoraproject.org/flatpaks/flatpak-runtime/c/bbb89f6b785133ef5d57c08a6d09d730c631d069?branch=f45
Log:
Add a .flake8 to suppress warnings and fix up other warnings
Add a .flake8 to suppress warnings it would take a lot of code churn t
fix, and start fixing up other warnings from Flake8 and vscode pylance
---
diff --git a/.flake8 b/.flake8
new file mode 100644
index 0000000..c0f7da3
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,9 @@
+[flake8]
+max-line-length = 100
+ignore =
+ # For now, ignore rules about blank lines
+ E302, E305, E306,
+ # For now, ignore wanring about using .format
+ FS002,
+ # Ignore "Line break occurred before a binary operator"
+ W503
\ No newline at end of file
diff --git a/README.md b/README.md
index 78fe884..379a86a 100644
--- a/README.md
+++ b/README.md
@@ -15,9 +15,8 @@ Updating
You also need `python3-jinja2` and possibly a few other Python
packages installed.
-And finally, you'll need to have [fedmod](https://pagure.io/modularity/fedmod) installed.
-You should run `fedmod fetch-metadata` initially and whenever you want to download
-a fresh set of metadata from Fedora. `fedmod` never updates metadata on its own.
+And finally, you'll need to have
+[flatpak-module-tools](https://pagure.io/flatpak-module-tools) installed.
*How it works*: The files in the upstream runtimes are the primary source for the contents
of the corresponding Fedora runtimes. When you type `make update`, the
diff --git a/tools/generate-app-reports.py b/tools/generate-app-reports.py
index 081c820..5d682c7 100755
--- a/tools/generate-app-reports.py
+++ b/tools/generate-app-reports.py
@@ -78,7 +78,7 @@ id_mappings = {
'Zoom': 'us.zoom.Zoom',
}
-for k, v in { k: v for k, v in id_mappings.items() }.items():
+for k, v in {k: v for k, v in id_mappings.items()}.items():
id_mappings[v] = k
@@ -98,7 +98,6 @@ def make_desktop_map(repo_info):
if old is None or util.package_cmp(package_info, old) < 0:
desktop_map[desktop_id] = package_info
-
util.foreach_file(repo_info, cb)
for k in desktop_map:
@@ -141,6 +140,7 @@ class Application:
if self.name is not None:
return self.name
else:
+ assert self.odrs_id
if self.odrs_id.endswith('.desktop'):
return self.odrs_id[0:-8]
else:
@@ -201,11 +201,13 @@ for app in iterate_apps(flathub_store):
if homepage != 'http://elementary.io/' and homepage != "http://www.w1hkj.com" and \
homepage != 'https://www.chocolate-doom.org/':
homepage_app = homepage_to_application.get(homepage, None)
+ else:
+ homepage_app = None
if name_app is not None and homepage_app is not None:
if name_app is not homepage_app:
- print("Please check whether there are more Flatpaks associated with the \"", homepage, \
- "\" homepage (by inspecting out/fedora-appstream.xml.gz). If yes, " \
+ print("Please check whether there are more Flatpaks associated with the \"", homepage,
+ "\" homepage (by inspecting out/fedora-appstream.xml.gz). If yes, "
"please add an exception into tools/generate-app-reports.py.", file=sys.stderr)
assert name_app is homepage_app
if name_app is not None:
@@ -258,7 +260,10 @@ def load_fedora_flatpaks():
page = 1
retrieved = 0
while True:
- response = requests.get(f'https://src.fedoraproject.org/api/0/projects?namespace=flatpaks&fork=false&page={page}&per_page=100')
+ response = requests.get(
+ 'https://src.fedoraproject.org/'
+ f'api/0/projects?namespace=flatpaks&fork=false&page={page}&per_page=100'
+ )
response.raise_for_status()
data = response.json()
@@ -294,7 +299,9 @@ top_packaged_apps = sorted(packaged_apps, key=lambda a: a.package)
top_packaged_apps.sort(key=lambda a: -(a.star_total or 0))
top_packaged_apps = top_packaged_apps[0:100]
-info_json = subprocess.check_output(['fedmod', DATASET_ARG, 'flatpak-report'] + [a.package for a in packaged_apps])
+info_json = subprocess.check_output(
+ ['fedmod', DATASET_ARG, 'flatpak-report'] + [a.package for a in packaged_apps]
+)
info = json.loads(info_json)
for a in packaged_apps:
a.extra_packages = info['flatpaks'][a.package]['extra']
@@ -303,11 +310,13 @@ runtime_packages = {}
extra_packages = {}
for p, i in info['packages'].items():
if i['runtime']:
- runtime_packages[p] = { 'all': i['used_by']}
+ runtime_packages[p] = {'all': i['used_by']}
else:
- extra_packages[p] = { 'all': i['used_by']}
+ extra_packages[p] = {'all': i['used_by']}
-top_info_json = subprocess.check_output(['fedmod', DATASET_ARG, 'flatpak-report'] + [a.package for a in top_packaged_apps])
+top_info_json = subprocess.check_output(
+ ['fedmod', DATASET_ARG, 'flatpak-report'] + [a.package for a in top_packaged_apps]
+)
top_info = json.loads(top_info_json)
for p, i in top_info['packages'].items():
@@ -339,19 +348,23 @@ with open('reports/application-packages.json', 'w') as f:
'extra': dict_to_list(extra_packages),
}, f, indent=4, sort_keys=True)
-def sanitize_piece(m):
+def sanitize_piece(m: re.Match[str]):
if m.group(1) is not None:
return m.group(1)
elif m.group(2) is not None:
return '<'
elif m.group(3) is not None:
return '>'
+ else:
+ assert False
def sanitize_description(description):
# This is specifically for a buggy appstream for GNOME Screenshot
description = re.sub(r'<p xml:lang="[^"]*">.*</p>', '', description)
# Main part of the sanitization - quote all <>&
- description = re.sub(r'(<p>|</p>|<ul>|</ul>|<li>|</li>|[^<>]+)|(<)|(>)', sanitize_piece, description)
+ description = re.sub(
+ r'(<p>|</p>|<ul>|</ul>|<li>|</li>|[^<>]+)|(<)|(>)', sanitize_piece, description
+ )
return description
for a in sorted(apps, key=lambda a: (locale.strxfrm(a.display_name), a.canon_id)):
@@ -387,14 +400,19 @@ for a in sorted(apps, key=lambda a: (locale.strxfrm(a.display_name), a.canon_id)
output_item['extra_packages'] = a.extra_packages
if a.star_total is not None:
- output_item['star_avg'] = sum((i * a.stars[i]) for i in range(0, 6))/sum((a.stars[i]) for i in range(0, 6))
+ output_item['star_avg'] = (
+ sum((i * a.stars[i]) for i in range(0, 6))
+ / sum((a.stars[i]) for i in range(0, 6))
+ )
output_item['star_total'] = a.star_total
output_item['stars'] = a.stars
output_item['fedora_flatpak'] = a.package is not None and a.package in fedora_flatpaks
output.append(output_item)
-# print(a.display_name, a.package, a.flathub_id, a.fedora_id, a.odrs_id, a.homepage, a.star_total)
+# print(
+# a.display_name, a.package, a.flathub_id, a.fedora_id, a.odrs_id, a.homepage, a.star_total
+# )
with open('reports/applications.json', 'w') as f:
json.dump({
diff --git a/tools/generate-runtime-report.py b/tools/generate-runtime-report.py
index 41c6ea4..7535298 100755
--- a/tools/generate-runtime-report.py
+++ b/tools/generate-runtime-report.py
@@ -11,7 +11,9 @@ import util
from util import BASEONLY, DATASET_ARG
def start(msg):
- print("{}: \033[90m{} ... \033[39m".format(os.path.basename(sys.argv[0]), msg), file=sys.stderr, end="")
+ print("{}: \033[90m{} ... \033[39m".format(
+ os.path.basename(sys.argv[0]), msg), file=sys.stderr, end=""
+ )
sys.stderr.flush()
def done():
@@ -23,9 +25,8 @@ def warn(msg):
def fedmod_output(args):
return subprocess.check_output(['fedmod', DATASET_ARG] + args, encoding='utf-8')
-_nvr_to_name_re = re.compile('^(.*)-[^-]*-[^-]*')
def nvr_to_name(nvr):
- return _nvr_to_name_re.match(nvr).group(1)
+ return nvr.rsplit("-", 2)[0]
def make_devel_packages(repo_info):
devel_packages = {}
@@ -63,7 +64,10 @@ class Package(object):
@property
def runtimes(self):
- return self.freedesktop_platform or self.gnome_platform or self.freedesktop_sdk or self.gnome_sdk
+ return (self.freedesktop_platform
+ or self.gnome_platform
+ or self.freedesktop_sdk
+ or self.gnome_sdk)
@property
def klass(self):
@@ -101,7 +105,7 @@ class Package(object):
if files is None:
files_str = ''
elif len(files) <= 3:
- files_str= 'Files: ' + ' '.join(files)
+ files_str = 'Files: ' + ' '.join(files)
else:
files_str = 'Files: ' + ' '.join(files[:3]) + ' ...'
@@ -110,7 +114,7 @@ class Package(object):
required_by_str = ''
else:
required_by = sorted(required_by, key=lambda x: x[0])
- required_by_str = '\n'.join('{} ({})'.format(req, provider) for req, provider in required_by)
+ required_by_str = '\n'.join(f"{req} ({provider})" for req, provider in required_by)
if files_str and required_by_str:
return files_str + '\n' + required_by_str
@@ -147,12 +151,14 @@ class Package(object):
required_by = getattr(self, which + '_required_by', False)
if required_by is False:
return 'present'
- elif required_by is not None and len(required_by) > 0:
- return 'files'
- elif self.flag is not None and self.flag.startswith('E'):
- return 'extra'
else:
- return 'root'
+ assert required_by is None or isinstance(required_by, list)
+ if required_by is not None and len(required_by) > 0:
+ return 'files'
+ elif self.flag is not None and self.flag.startswith('E'):
+ return 'extra'
+ else:
+ return 'root'
@property
def freedesktop_platform_inclusion(self):
@@ -185,10 +191,6 @@ class SourcePackage(object):
self.packages = []
@property
- def sdk_only(self):
- return sdk_only
-
- @property
def klass(self):
return ""
@@ -252,7 +254,8 @@ def add_packages(source, which, resolve_deps=False, only_if_exists=False):
continue
provider = nvr_to_name(providers[0])
provider_package = packages.get(provider, None)
- if provider_package is None: # filtered out of the resolve-deps output - e.g., fedora-release
+ if provider_package is None:
+ # filtered out of the resolve-deps output - e.g., fedora-release
continue
required_by = getattr(provider_package, which + '_required_by')
if required_by is None:
@@ -270,7 +273,7 @@ def add_package_files(filename, which):
with open(filename) as f:
for line in f:
f, p = line.strip().rsplit(' ', 1)
- f = f[:-1] # strip trailing :
+ f = f[:-1] # strip trailing :
pkg = packages[p]
old = getattr(pkg, which + '_files')
if old is not None:
@@ -312,6 +315,9 @@ def read_package_notes():
else:
flag = None
note = parts[1] + ':' + parts[2]
+ else:
+ warn("package note does not have 1, 2 or 3 parts: {}".format(line))
+ continue
yield name, note, flag
@@ -370,11 +376,11 @@ for package in packages.values():
letters_map = dict()
for k, v in source_packages.items():
v.packages.sort(key=lambda p: locale.strxfrm(p.name))
- l = v.name[0].upper()
- letter = letters_map.get(l, None)
+ first_to_upper = v.name[0].upper()
+ letter = letters_map.get(first_to_upper, None)
if letter is None:
- letter = Letter(l)
- letters_map[l] = letter
+ letter = Letter(first_to_upper)
+ letters_map[first_to_upper] = letter
letter.packages.append(v)
letters = []
diff --git a/tools/resolve-files.py b/tools/resolve-files.py
index 501cbd8..8ba6c94 100755
--- a/tools/resolve-files.py
+++ b/tools/resolve-files.py
@@ -164,7 +164,7 @@ bin_ignore = [
'pcregrep', 'pcretest',
'pcre2grep', 'pcre2test',
- #pulseaudio-utils
+ # pulseaudio-utils
'pacat', 'pacmd', 'pactl', 'padsp', 'pamon',
'paplay', 'parec', 'parecord', 'pax11publish',
@@ -242,7 +242,7 @@ bin_rename = {
'valac-0.52': 'valac-0.56',
'vapigen-0.52': 'vapigen-0.56',
}
-rename.update({ '/usr/bin/' + k: '/usr/bin/' + v for k, v in bin_rename.items() })
+rename.update({'/usr/bin/' + k: '/usr/bin/' + v for k, v in bin_rename.items()})
lib_ignore = [
# Symlink created in freedesktop.org flatpak runtime, not standard
@@ -324,14 +324,14 @@ lib_rename = {
# Fedora arch-handling
'ld-linux.so.2': 'ld-linux-x86-64.so.2',
}
-rename.update({ '/usr/lib64/' + k: '/usr/lib64/' + v for k, v in lib_rename.items() })
+rename.update({'/usr/lib64/' + k: '/usr/lib64/' + v for k, v in lib_rename.items()})
gcc_libs = [
'libasan.so', 'libatomic.so', 'libgcc_s.so', 'libgfortran.so', 'libgomp.so',
'libitm.so', 'liblsan.so', 'libquadmath.so', 'libstdc++.so', 'libtsan.so',
'libubsan.so'
]
-rename.update({ '/usr/lib64/' + x: '/usr/lib/gcc/x86_64-redhat-linux/13/' + x for x in gcc_libs })
+rename.update({'/usr/lib64/' + x: '/usr/lib/gcc/x86_64-redhat-linux/13/' + x for x in gcc_libs})
for old in ['libasm-0.187.so', 'libdw-0.187.so', 'libelf-0.187.so', 'libdebuginfod-0.187.so']:
rename['/usr/lib64/' + old] = '/usr/lib64/' + old.replace('-0.187', '-0.189')
@@ -366,13 +366,13 @@ nspr_include = [
'prsystem.h', 'prthread.h', 'prtime.h', 'prtpool.h', 'prtrace.h', 'prtypes.h', 'prvrsion.h',
'prwin16.h', 'stropts.h', 'obsolete/pralarm.h', 'obsolete/probslet.h', 'obsolete/protypes.h', 'obsolete/prsem.h'
]
-rename.update({ '/usr/include/' + x: '/usr/include/nspr4/' + x for x in nspr_include })
+rename.update({'/usr/include/' + x: '/usr/include/nspr4/' + x for x in nspr_include})
# pipewire jack libraries are installed in a non-standard path
jack_libraries = [
'libjack.so', 'libjacknet.so', 'libjackserver.so'
]
-rename.update({ '/usr/lib64/' + x: '/usr/lib64/pipewire-0.3/jack/' + x for x in jack_libraries })
+rename.update({'/usr/lib64/' + x: '/usr/lib64/pipewire-0.3/jack/' + x for x in jack_libraries})
# These plugins in the freedesktop runtime pull in gstreamer-plugins-bad-free-extras, which
# in turn pulls in a lot more dependencies. If they are useful, they should be moved
@@ -411,18 +411,18 @@ pc_rename = {
'python-3.10-embed.pc': 'python-3.11-embed.pc',
'vapigen-0.52.pc': 'vapigen-0.56.pc',
}
-rename.update({ '/usr/lib64/pkgconfig/' + k: '/usr/lib64/pkgconfig/' + v for k, v in pc_rename.items() })
-rename.update({ '/usr/share/pkgconfig/' + k: '/usr/share/pkgconfig/' + v for k, v in pc_rename.items() })
+rename.update({'/usr/lib64/pkgconfig/' + k: '/usr/lib64/pkgconfig/' + v for k, v in pc_rename.items()})
+rename.update({'/usr/share/pkgconfig/' + k: '/usr/share/pkgconfig/' + v for k, v in pc_rename.items()})
hunspell_ignore = {
- # regionless symlinks, correctly detected by full xx_XX name
- 'gl.aff', 'gl.dic', 'is.aff', 'is.dic', 'te.aff', 'te.dic', 'tr.aff', 'tr.dic',
+ # regionless symlinks, correctly detected by full xx_XX name
+ 'gl.aff', 'gl.dic', 'is.aff', 'is.dic', 'te.aff', 'te.dic', 'tr.aff', 'tr.dic',
}
ignore.update('/usr/share/hunspell/' + x for x in hunspell_ignore)
hyph_ignore = {
- # regionless symlinks, correctly detected by full xx_XX name
- 'hyph_de.dic', 'hyph_gl.dic', 'hyph_is.dic', 'hyph_te.dic',
+ # regionless symlinks, correctly detected by full xx_XX name
+ 'hyph_de.dic', 'hyph_gl.dic', 'hyph_is.dic', 'hyph_te.dic',
}
ignore.update('/usr/share/hyphen/' + x for x in hyph_ignore)
@@ -527,9 +527,9 @@ global_package_ignore_patterns = [
'^v4l-utils-devel-tools$',
'^xdg-desktop-portal$',
'^xdg-desktop-portal-devel$',
- '^openssl1\.1-devel$', # conflicts with openssl-devel from openssl 3.0
- '^golang-github-xo-terminfo$', # conflicts on /usr/bin/infocmp with ncurses
- '^elfutils-debuginfod$', # we don't need debuginfod server
+ r'^openssl1\.1-devel$', # conflicts with openssl-devel from openssl 3.0
+ '^golang-github-xo-terminfo$', # conflicts on /usr/bin/infocmp with ncurses
+ '^elfutils-debuginfod$', # we don't need debuginfod server
]
global_package_ignore_compiled = [re.compile(p) for p in global_package_ignore_patterns]
@@ -537,12 +537,12 @@ global_package_ignore_compiled = [re.compile(p) for p in global_package_ignore_p
platform_package_ignore_patterns = [
"^.*-devel$",
"^libappstream-glib-builder$", # may not need in the sdk either
- "^gcc-gdb-plugin$", # pulls in gcc
+ "^gcc-gdb-plugin$", # pulls in gcc
"^gtk-doc$",
"^gtk4-devel-tools$",
- "^icu$", # may not need in the sdk either
+ "^icu$", # may not need in the sdk either
'^llvm$',
- '^llvm-test$', # pulls in gcc and binutils
+ '^llvm-test$', # pulls in gcc and binutils
'^sqlite$',
]
platform_package_ignore_compiled = [re.compile(p) for p in platform_package_ignore_patterns]
@@ -579,8 +579,8 @@ start("Reading file list")
to_resolve = []
with open(inpath) as f:
- for l in f:
- r = l.rstrip()
+ for line in f:
+ r = line.rstrip()
if r.startswith('/usr/lib/x86_64-linux-gnu/'):
r = '/usr/lib64/' + r[len('/usr/lib/x86_64-linux-gnu/'):]
elif r.startswith('/usr/lib/'):
@@ -637,6 +637,8 @@ for r in to_resolve:
providing = files_map.get(s, None)
if providing is not None:
break
+ else:
+ providing = None
if providing is None:
print(r, file=unmatched_file)
diff --git a/tools/util.py b/tools/util.py
index ddef6fa..08217c3 100644
--- a/tools/util.py
+++ b/tools/util.py
@@ -84,9 +84,11 @@ def package_cmp(p1, p2):
elif n1.startswith('python3-') and n2.startswith('python2-'):
return -1
- if n1.startswith('jack-audio-connection-kit') and n2.startswith('pipewire-jack-audio-connection-kit'):
+ if (n1.startswith('jack-audio-connection-kit')
+ and n2.startswith('pipewire-jack-audio-connection-kit')):
return 1
- elif n1.startswith('pipewire-jack-audio-connection-kit') and n2.startswith('jack-audio-connection-kit'):
+ elif (n1.startswith('pipewire-jack-audio-connection-kit')
+ and n2.startswith('jack-audio-connection-kit')):
return -1
if n1 < n2:
@@ -101,7 +103,7 @@ def package_cmp(p1, p2):
return - rpm.labelCompare((e1, v1, r1), (e2, v2, r2))
-class FilesMapHandler(xml.sax.handler.ContentHandler):
+class FilesMapHandler(xml.sax.ContentHandler):
def __init__(self, cb):
self.cb = cb
self.package_info = None
@@ -145,7 +147,9 @@ def foreach_file(repo_info, cb):
root = ET.fromstring(repomd_contents)
ns = {'repo': 'http://linux.duke.edu/metadata/repo'}
- filelists_location = root.find("./repo:data[@type='filelists']/repo:location", ns).attrib['href']
+ filelists_location_element = root.find("./repo:data[@type='filelists']/repo:location", ns)
+ assert filelists_location_element is not None
+ filelists_location = filelists_location_element.attrib['href']
filelists_path = os.path.join(repo_dir, filelists_location)
if os.path.commonprefix([filelists_path, repo_dir]) != repo_dir:
done()
@@ -157,7 +161,7 @@ def foreach_file(repo_info, cb):
done()
-class PackageMapHandler(xml.sax.handler.ContentHandler):
+class PackageMapHandler(xml.sax.ContentHandler):
def __init__(self, cb):
self.cb = cb
self.name = None
@@ -193,7 +197,9 @@ def foreach_package(repo_info, cb):
root = ET.fromstring(repomd_contents)
ns = {'repo': 'http://linux.duke.edu/metadata/repo'}
- filelists_location = root.find("./repo:data[@type='primary']/repo:location", ns).attrib['href']
+ filelists_location_element = root.find("./repo:data[@type='primary']/repo:location", ns)
+ assert filelists_location_element is not None
+ filelists_location = filelists_location_element.attrib['href']
filelists_path = os.path.join(repo_dir, filelists_location)
if os.path.commonprefix([filelists_path, repo_dir]) != repo_dir:
done()
@@ -216,7 +222,8 @@ def get_repo_cacheable(name, generate):
with open(repomd_path, 'rb') as f:
repomd_contents = f.read()
except (OSError, IOError):
- print("Cannot read {}, try 'fedmod " + DATASET_ARG + " fetch-metadata'".format(repomd_path), file=sys.stderr)
+ print(f"Cannot read {repomd_path}, try 'fedmod {DATASET_ARG} fetch-metadata'",
+ file=sys.stderr)
sys.exit(1)
repo_info[repo] = (repo_dir, repomd_contents)
@@ -247,4 +254,3 @@ def get_repo_cacheable(name, generate):
done()
return data
-
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-11 14:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11 14:42 [flatpaks/flatpak-runtime] f45: Add a .flake8 to suppress warnings and fix up other warnings Owen W. Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox