[geany/www.geany.org] 2f42fb: Use f-strings and other minor linting fixes, reported by PyLint

Enrico Tröger git-noreply at xxxxx
Fri Oct 8 09:23:07 UTC 2021


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Fri, 08 Oct 2021 09:23:07 UTC
Commit:      2f42fbf7c4e70bb0a9956a1073402c74b130df9f
             https://github.com/geany/www.geany.org/commit/2f42fbf7c4e70bb0a9956a1073402c74b130df9f

Log Message:
-----------
Use f-strings and other minor linting fixes, reported by PyLint


Modified Paths:
--------------
    geany/decorators.py
    geany/management/commands/dump_database.py
    geany/settings.py
    geany/sitemaps.py
    geany/templatetags/geany_tags.py
    geany/urls_legacy.py
    geany/wsgi.py
    latest_version/models.py
    latest_version/releases.py
    news/admin.py
    news/views.py
    nightlybuilds/models.py
    pastebin/api/create.py
    pastebin/management/commands/cleanup_snippets.py
    pastebin/management/commands/generate_snippets_css.py
    pastebin/models.py
    pastebin/views.py
    static_docs/generate_i18n_statistics.py
    static_docs/github_client.py
    static_docs/views.py

Modified: geany/decorators.py
6 lines changed, 3 insertions(+), 3 deletions(-)
===================================================================
@@ -52,7 +52,7 @@ def do_cache(function):
         def wrapped(*args, **kwargs):
             cache_key = key
             if cache_key is None:
-                cache_key = '%s.%s' % ((function.__module__, function.__name__))
+                cache_key = f'{function.__module__}.{function.__name__}'
                 if args and not ignore_arguments:
                     cache_args = args
                     # don't include 'self' in arguments
@@ -61,10 +61,10 @@ def wrapped(*args, **kwargs):
                         cache_args = args[1:]
                     if cache_args:
                         cache_args_repr = repr(cache_args).encode('utf-8')
-                        cache_key = '%s.args%s' % (cache_key, hexlify(cache_args_repr))
+                        cache_key = f'{cache_key}.args{hexlify(cache_args_repr)}'
                 if kwargs and not ignore_arguments:
                     kwargs_repr = repr(kwargs).encode('utf-8')
-                    cache_key = '%s.kwargs%s' % (cache_key, hexlify(kwargs_repr))
+                    cache_key = f'{cache_key}.kwargs{hexlify(kwargs_repr)}'
             result = _djcache.get(cache_key)
             if result is None:
                 result = function(*args, **kwargs)


Modified: geany/management/commands/dump_database.py
10 lines changed, 5 insertions(+), 5 deletions(-)
===================================================================
@@ -47,7 +47,7 @@ def _dump_main_database(self):
     # ----------------------------------------------------------------------
     def _remove_sensitive_information_from_dump(self):
         # remove potential sensitive information
-        with open('database.json') as data_input:
+        with open('database.json', encoding='utf-8') as data_input:
             data = load(data_input)
             for record in data:
                 model = record['model']
@@ -82,7 +82,7 @@ def _remove_sensitive_information_from_dump(self):
             data.append(user)
 
         # write data back to the database file
-        with open('database.json', 'w') as output:
+        with open('database.json', 'w', encoding='utf-8') as output:
             dump(data, output, indent=2)
 
     # ----------------------------------------------------------------------
@@ -116,10 +116,10 @@ def _dump_nightly_builds_database(self):
 
         # merge the nightly build dump files
         filenames = (database_nightlybuilds_filename, database_nightlybuild_targets_filename)
-        records = list()
-        with open('database_nightlybuilds.json', 'w') as output:
+        records = []
+        with open('database_nightlybuilds.json', 'w', encoding='utf-8') as output:
             for filename in filenames:
-                with open(filename) as infile:
+                with open(filename, encoding='utf-8') as infile:
                     data = load(infile)
                     records.extend(data)
 


Modified: geany/settings.py
7 lines changed, 4 insertions(+), 3 deletions(-)
===================================================================
@@ -257,7 +257,7 @@
 MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))
 
 # Package/module name to import the root urlpatterns from for the project.
-ROOT_URLCONF = "%s.urls" % PROJECT_APP
+ROOT_URLCONF = f'{PROJECT_APP}.urls'
 
 TEMPLATES = [
     {
@@ -630,11 +630,12 @@ def skip_404_not_found(record):
 if os.path.exists(filename):
     from importlib.util import module_from_spec, spec_from_file_location
     import sys
-    module_name = '{}.local_settings'.format(PROJECT_APP)  # pylint: disable=invalid-name
+    module_name = f'{PROJECT_APP}.local_settings'  # pylint: disable=invalid-name
     spec = spec_from_file_location(module_name, filename)  # pylint: disable=invalid-name
     module = module_from_spec(spec)  # pylint: disable=invalid-name
     sys.modules[module_name] = module
-    exec(open(filename, 'rb').read())  # pylint: disable=exec-used
+    with open(filename, 'rb') as local_config:
+        exec(local_config.read())  # pylint: disable=exec-used
 
 
 ####################


Modified: geany/sitemaps.py
8 lines changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -95,7 +95,7 @@ class StaticSitemap(sitemaps.Sitemap):
     def __init__(self, domain, patterns, exclude_views=None):
         self._domain = domain
         self._patterns = patterns
-        self._exclude_views = exclude_views or list()
+        self._exclude_views = exclude_views or []
         self._site = None
         self._url_mapping = {}
         self._get_site()
@@ -131,7 +131,7 @@ def _resolve_url(self, url):
 
     # ----------------------------------------------------------------------
     def get_dynamic_items(self):
-        return list()
+        return []
 
     # ----------------------------------------------------------------------
     def changefreq(self, obj):  # pylint: disable=unused-argument
@@ -151,7 +151,7 @@ class SitemapRegistry:
 
     # ----------------------------------------------------------------------
     def __init__(self):
-        self._sitemap_generators = list()
+        self._sitemap_generators = []
         self._static_items = None
         self._site = None
 
@@ -179,7 +179,7 @@ def _get_static_items(self):
 
     # ----------------------------------------------------------------------
     def _get_items(self, item_generator_name):
-        items = list()
+        items = []
         for generator_class, url_patterns, site_domain, exclude_views in self._sitemap_generators:
             site_domain = self._get_site_domain_or_default(site_domain)
             generator = generator_class(


Modified: geany/templatetags/geany_tags.py
7 lines changed, 4 insertions(+), 3 deletions(-)
===================================================================
@@ -38,7 +38,7 @@ def render(self, context):
             rendered_content = content_template.render(context)
             context[self._target_var_name] = rendered_content
         except (template.VariableDoesNotExist, template.TemplateSyntaxError) as exc:
-            return 'Error rendering: {}'.format(exc)
+            return f'Error rendering: {exc}'
 
         return ''
 
@@ -52,8 +52,9 @@ def do_evaluate(parser, token):  # pylint: disable=unused-argument
     try:
         _, variable, _, target_var_name = token.split_contents()
     except ValueError as exc:
+        token_name = token.contents.split()[1]
         raise template.TemplateSyntaxError(
-            '{!r} tag requires a single argument'.format(token.contents.split()[1])) from exc
+            f'{token_name!r} tag requires a single argument') from exc
     return EvaluateNode(variable, target_var_name)
 
 
@@ -63,6 +64,6 @@ def add_css(field, css):
     # read existing CSS classes
     css_classes = field.field.widget.attrs.get('class', '')
     # add new ones
-    css_classes = '{} {}'.format(css_classes, css)
+    css_classes = f'{css_classes} {css}'
     # render the widget
     return field.as_widget(attrs={'class': css_classes})


Modified: geany/urls_legacy.py
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -189,13 +189,13 @@ def _add_url_mappings(mapping, urlpatterns_):
             old_url = old_url[1:]
 
         url_pattern = url(
-            r'^{}$'.format(old_url),
+            fr'^{old_url}$',
             RedirectView.as_view(url=new_url, permanent=True))
         urlpatterns_.append(url_pattern)
         # add pattern variant with trailing slash
         if old_url[-1] != '/':
             url_pattern = url(
-                r'^{}/$'.format(old_url),
+                fr'^{old_url}/$',
                 RedirectView.as_view(url=new_url, permanent=True))
             urlpatterns_.append(url_pattern)
 


Modified: geany/wsgi.py
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -14,7 +14,7 @@
 
 
 os.environ.setdefault(
-    "DJANGO_SETTINGS_MODULE",
-    "{}.settings".format(real_project_name("geany")))
+    'DJANGO_SETTINGS_MODULE',
+    f'{real_project_name("geany")}.settings')
 
 application = get_wsgi_application()


Modified: latest_version/models.py
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -48,4 +48,4 @@ def save(self, *args, **kwargs):  # pylint: disable=signature-differs
 
     # ----------------------------------------------------------------------
     def __str__(self):
-        return '{} {}'.format(self.name, self.version)
+        return f'{self.name} {self.version}'


Modified: latest_version/releases.py
15 lines changed, 6 insertions(+), 9 deletions(-)
===================================================================
@@ -93,7 +93,7 @@ def provide(self):
 
     # ----------------------------------------------------------------------
     def _fetch_releases_from_filesystem(self):
-        self._release_files = list()
+        self._release_files = []
 
         if not self._releases_directory:
             return
@@ -109,10 +109,10 @@ def _fetch_releases_from_filesystem(self):
 
     # ----------------------------------------------------------------------
     def _group_releases_by_type(self):
-        self._release_files_by_version = dict()
+        self._release_files_by_version = {}
         release_types = self._get_release_types()
         for release_type in release_types:
-            self._release_files_by_version[release_type] = list()
+            self._release_files_by_version[release_type] = []
 
         for filename in self._release_files:
             for release_type in release_types:
@@ -122,7 +122,7 @@ def _group_releases_by_type(self):
 
     # ----------------------------------------------------------------------
     def _get_release_types(self):
-        return RELEASE_TYPES.get(self._releases_directory, dict())
+        return RELEASE_TYPES.get(self._releases_directory, {})
 
     # ----------------------------------------------------------------------
     def _factor_release_versions(self):
@@ -139,14 +139,11 @@ def _determine_latest_version(self, release_type):
         release_types = self._get_release_types()
         try:
             latest_version = sorted_versions.pop()
-            logger.debug(
-                'Latest version found for "{}": {}'.format(release_type, latest_version))
+            logger.debug('Latest version found for "%s": %s', release_type, latest_version)
         except IndexError:
             fallback_filename = release_types[release_type]['fallback_filename']
             latest_version = fallback_filename.format(version=self._fallback_version)
             logger.debug(
-                'Latest version found for "{}": {} (fallback)'.format(
-                    release_type,
-                    latest_version))
+                'Latest version found for "%s": %s (fallback)', release_type, latest_version)
 
         return latest_version


Modified: news/admin.py
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -42,7 +42,7 @@ def _toggle_many_published(self, request, queryset):
         for newspost in queryset:
             self._toggle_newspost_published_status(newspost)
             rows_updated += 1
-        self.message_user(request, "{} News posts were successfully changed.".format(rows_updated))
+        self.message_user(request, f'{rows_updated} News posts were successfully changed.')
 
     # ----------------------------------------------------------------------
     def _toggle_newspost_published_status(self, newspost):
@@ -52,7 +52,7 @@ def _toggle_newspost_published_status(self, newspost):
             newspost.status = CONTENT_STATUS_PUBLISHED
         newspost.save()
 
-    _toggle_many_published.short_description = "Toggle the published status of selected News posts"
+    _toggle_many_published.short_description = 'Toggle the published status of selected News posts'
 
 
 admin.site.register(NewsPost, NewsPostAdmin)


Modified: news/views.py
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -59,7 +59,7 @@ def post(self, request, *args, **kwargs):  # pylint: disable=unused-argument
         try:
             newspost = NewsPost.objects.get(slug=newspost_slug)
         except NewsPost.DoesNotExist:
-            error_message = 'News post item for "{}" could not be found'.format(newspost_slug)
+            error_message = f'News post item for "{newspost_slug}" could not be found'
             result = dict(error=error_message)
         else:
             # adapt to dict


Modified: nightlybuilds/models.py
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -36,7 +36,7 @@ class Meta:
 
     # ----------------------------------------------------------------------
     def __str__(self):
-        return '{} {}'.format(self.name, self.arch)
+        return f'{self.name} {self.arch}'
 
 
 class NightlyBuild(models.Model):
@@ -71,4 +71,4 @@ def get_status_text(self):
 
     # ----------------------------------------------------------------------
     def __str__(self):
-        return '{} {}'.format(self.build_date, self.nightly_build_target)
+        return f'{self.build_date} {self.nightly_build_target}'


Modified: pastebin/api/create.py
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -96,7 +96,7 @@ def _validate_passed_fields(self):
         additional_fields = provided_fields.difference(self.valid_fields)
         if additional_fields:
             raise SnippetValidationError(
-                'Invalid fields provided (%s)' % ','.join(additional_fields))
+                f'Invalid fields provided ({",".join(additional_fields)})')
 
     # ----------------------------------------------------------------------
     def _validate_against_snippet_form(self):
@@ -109,7 +109,7 @@ def _validate_against_snippet_form(self):
         # validate
         if not snippet_form.is_valid():
             errors = '\n'.join(
-                ['%s: %s' % (k, v.as_text()) for k, v in snippet_form.errors.items()])
+                [f'{k}: {v.as_text()}' for k, v in snippet_form.errors.items()])
             raise SnippetValidationError(errors)
         self._snippet_form = snippet_form
 


Modified: pastebin/management/commands/cleanup_snippets.py
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -35,10 +35,10 @@ def add_arguments(self, parser):
     # ----------------------------------------------------------------------
     def handle(self, *args, **options):
         deleteable_snippets = Snippet.objects.filter(expires__lte=timezone.now())
-        sys.stdout.write('{} snippets gets deleted:\n'.format(deleteable_snippets.count()))
+        sys.stdout.write(f'{deleteable_snippets.count()} snippets gets deleted:\n')
         for deleteable_snippet in deleteable_snippets:
             sys.stdout.write(
-                u'- {} ({})\n'.format(deleteable_snippet.secret_id, deleteable_snippet.expires))
+                f'- {deleteable_snippet.secret_id} ({deleteable_snippet.expires})\n')
         if options.get('dry_run'):
             sys.stdout.write('Dry run - Doing nothing! *crossingfingers*\n')
         else:


Modified: pastebin/management/commands/generate_snippets_css.py
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -22,6 +22,6 @@ class Command(BaseCommand):
 
     # ----------------------------------------------------------------------
     def handle(self, *args, **options):
-        with open('pastebin/static/css/pygments.css', 'w') as css_file:
+        with open('pastebin/static/css/pygments.css', 'w', encoding='utf-8') as css_file:
             # You can change style and the html class here:
             css_file.write(HtmlFormatter(style='colorful').get_style_defs('.highlight'))


Modified: pastebin/models.py
12 lines changed, 6 insertions(+), 6 deletions(-)
===================================================================
@@ -83,13 +83,13 @@ def _readable_delta(self, from_seconds, until_seconds=None):
 
         # show a fuzzy but useful approximation of the time delta
         if delta.days:
-            return '%d days ago' % (delta.days)
+            return f'{delta.days} days ago'
         elif delta_hours:
-            return '%d hours ago' % (delta_hours)
+            return f'{delta_hours} hours ago'
         elif delta_minutes:
-            return '%d minutes ago' % (delta_minutes)
+            return f'{delta_minutes} minutes ago'
         else:
-            return '%d seconds ago' % (delta.seconds)
+            return f'{delta.seconds} seconds ago'
 
     # ----------------------------------------------------------------------
     def get_linecount(self):
@@ -123,7 +123,7 @@ def get_absolute_url(self):
 
     # ----------------------------------------------------------------------
     def __str__(self):
-        return '{}'.format(self.secret_id)
+        return f'{self.secret_id}'
 
 
 class SpamwordManager(models.Manager):
@@ -141,4 +141,4 @@ class Spamword(models.Model):
 
     # ----------------------------------------------------------------------
     def __str__(self):
-        return '{}'.format(self.word)
+        return f'{self.word}'


Modified: pastebin/views.py
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -52,7 +52,7 @@ def _get_snippet_list(no_content=False):
         snippet_list = list(queryset[:max_snippets])
         cache.set(cache_key, snippet_list, CACHE_TIMEOUT_24HOURS)
     except ValueError:
-        snippet_list = list()
+        snippet_list = []
     return snippet_list
 
 
@@ -203,7 +203,7 @@ def post(self, request):
 
         site = self._get_site(request)
         absolute_url = snippet.get_absolute_url()
-        result = 'https://{}{}'.format(site.domain, absolute_url)
+        result = f'https://{site.domain}{absolute_url}'
         return HttpResponse(result, content_type='text/plain')
 
     # ----------------------------------------------------------------------


Modified: static_docs/generate_i18n_statistics.py
18 lines changed, 9 insertions(+), 9 deletions(-)
===================================================================
@@ -134,7 +134,7 @@ def _update_pot_file(self):
 
     # ----------------------------------------------------------------------
     def _factor_pot_filename(self):
-        return join(self._destination_path, '{}.pot'.format(self._domain))
+        return join(self._destination_path, f'{self._domain}.pot')
 
     # ----------------------------------------------------------------------
     def _execute_command(self, command):
@@ -150,11 +150,11 @@ def _execute_command(self, command):
             output_utf8 = output.decode('utf-8')
             return output_utf8
         except CalledProcessError as exc:
+            command_line = ' '.join(command)
+            error_message = exc.output.decode('utf-8')
             raise ValueError(
-                'Command: "{}" exited with code {}: {}'.format(
-                    ' '.join(command),
-                    exc.returncode,
-                    exc.output.decode('utf-8'))) from exc
+                f'Command: "{command_line}" exited with code {exc.returncode}: {error_message}'
+            ) from exc
 
     # ----------------------------------------------------------------------
     def _fetch_pot_stats(self):
@@ -172,7 +172,7 @@ def _read_po_translation_statistics(self, filename):
             fuzzy = match.group('fuzzy')
             untranslated = match.group('untranslated')
         else:
-            raise ValueError('Unable to parse msgfmt output: {}'.format(output))
+            raise ValueError(f'Unable to parse msgfmt output: {output}')
 
         return TranslationStatistics(
             translated=int(translated) if translated is not None else 0,
@@ -181,7 +181,7 @@ def _read_po_translation_statistics(self, filename):
 
     # ----------------------------------------------------------------------
     def _fetch_message_catalogs(self):
-        self._message_catalogs = list()
+        self._message_catalogs = []
         for po_filename in listdir(self._source_path):
             basename, extension = splitext(po_filename)
             if extension == '.po':
@@ -198,7 +198,7 @@ def _fetch_message_catalogs(self):
     # ----------------------------------------------------------------------
     def _read_last_translator(self, filename):
         filename = join(self._source_path, filename)
-        with open(filename) as file_:
+        with open(filename, encoding='utf-8') as file_:
             for line in file_:
                 if line.startswith('"Last-Translator:'):
                     match = LAST_TRANSLATOR_REGEXP.match(line)
@@ -252,5 +252,5 @@ def _factor_overall_statistics(self):
     # ----------------------------------------------------------------------
     def _write_overall_statistics(self):
         output_filename = join(self._destination_path, self._target_filename)
-        with open(output_filename, 'w') as output_file:
+        with open(output_filename, 'w', encoding='utf-8') as output_file:
             dump(self._overall_statistics, output_file, cls=SimpleObjectToJSONEncoder)


Modified: static_docs/github_client.py
35 lines changed, 12 insertions(+), 23 deletions(-)
===================================================================
@@ -37,11 +37,7 @@ def __init__(self, auth_token=None):
     def get_file_contents(self, filename, user=None, repository=None):
         user = user or GITHUB_USER
         repository = repository or GITHUB_REPOSITORY
-        url = '{api_base_url}repos/{user}/{repository}/contents/{filename}'.format(
-            api_base_url=GITHUB_API_URL,
-            user=user,
-            repository=repository,
-            filename=filename)
+        url = f'{GITHUB_API_URL}repos/{user}/{repository}/contents/{filename}'
         response = self._request(url)
         response_json = response.json()
 
@@ -71,16 +67,17 @@ def _request(self, url, status_404_expected=False):
 
     # ----------------------------------------------------------------------
     def _factor_authorization_header(self):
-        auth = '{}:x-oauth-basic'.format(self._auth_token)
+        auth = f'{self._auth_token}:x-oauth-basic'
         auth_encoded = auth.encode('ascii')
-        basic_auth_value = 'Basic {}'.format(standard_b64encode(auth_encoded).decode())
+        auth_base64 = standard_b64encode(auth_encoded).decode()
+        basic_auth_value = f'Basic {auth_base64}'
         return {'Authorization': basic_auth_value}
 
     # ----------------------------------------------------------------------
     def _log_rate_limit(self, response):
         rate_limit_remaining = int(response.headers['X-RateLimit-Remaining'])
         rate_limit = response.headers['X-RateLimit-Limit']
-        log_message = 'Github rate limits: {}/{}'.format(rate_limit_remaining, rate_limit)
+        log_message = f'Github rate limits: {rate_limit_remaining}/{rate_limit}'
         if rate_limit_remaining > 0:
             logger.info(log_message)
         else:
@@ -99,19 +96,20 @@ def _log_request(self, response, status_404_expected):
         else:
             reason = response.reason
 
-        log_message = 'Requesting "{} {}" took {}s: {} ({})'.format(
+        log_message = 'Requesting "%s %s" took %0.3fs: %s (%s)'
+        log_message_args = (
             response.request.method,
             response.request.url,
             response.elapsed.total_seconds(),
             response.status_code,
             reason)
 
         if response.status_code == 200:
-            logger.info(log_message)
+            logger.info(log_message, *log_message_args)
         elif response.status_code == 404 and status_404_expected:
-            logger.info(log_message)
+            logger.info(log_message, *log_message_args)
         else:
-            logger.warning(log_message)
+            logger.warning(log_message, *log_message_args)
 
     # ----------------------------------------------------------------------
     def _parse_fetch_file_response(self, response_json):
@@ -124,12 +122,7 @@ def _parse_fetch_file_response(self, response_json):
 
     # ----------------------------------------------------------------------
     def get_release_by_tag(self, tag_name):
-        url = '{api_base_url}repos/{user}/{repository}/releases/tags/{tag_name}'.format(
-            api_base_url=GITHUB_API_URL,
-            user=GITHUB_USER,
-            repository=GITHUB_REPOSITORY,
-            tag_name=tag_name)
-
+        url = f'{GITHUB_API_URL}repos/{GITHUB_USER}/{GITHUB_REPOSITORY}/releases/tags/{tag_name}'
         response = self._request(url, status_404_expected=True)
         if response:
             response_json = response.json()
@@ -139,11 +132,7 @@ def get_release_by_tag(self, tag_name):
 
     # ----------------------------------------------------------------------
     def get_latest_release(self):
-        url = '{api_base_url}repos/{user}/{repository}/releases/latest'.format(
-            api_base_url=GITHUB_API_URL,
-            user=GITHUB_USER,
-            repository=GITHUB_REPOSITORY)
-
+        url = f'{GITHUB_API_URL}repos/{GITHUB_USER}/{GITHUB_REPOSITORY}/releases/latest'
         response = self._request(url)
         response_json = response.json()
         return response_json


Modified: static_docs/views.py
14 lines changed, 7 insertions(+), 7 deletions(-)
===================================================================
@@ -53,7 +53,7 @@ def __init__(self):
 
     # ----------------------------------------------------------------------
     def __repr__(self):
-        return 'Geany %s (%s)' % (self.version, self.release_date)
+        return f'Geany {self.version} ({self.release_date})'
 
 
 class StaticDocsView(TemplateView):
@@ -98,7 +98,7 @@ def _get_release_notes(self):
 
     # ----------------------------------------------------------------------
     def _parse_news_file(self):
-        releases = list()
+        releases = []
         current_release = None
         current_release_notes = None
         for line in self._file_contents.splitlines():
@@ -116,13 +116,13 @@ def _parse_news_file(self):
                 current_release.version = version
                 current_release.release_date = date
                 releases.append(current_release)
-                current_release_notes = list()
+                current_release_notes = []
             else:
                 line = line.lstrip()  # remove any indentation
                 if line and not line.startswith('*'):
                     # we got a section: make it bold and add an additional new line
                     # to make Markdown recognise the following lines as list
-                    current_release_notes.append('**{}**\n'.format(line))
+                    current_release_notes.append(f'**{line}**\n')
                 else:
                     current_release_notes.append(line)
 
@@ -197,7 +197,7 @@ def _get_release_from_github(self, version=None):
     # ----------------------------------------------------------------------
     def _convert_version_to_tag_name(self, version):
         if version.count('.') == 1:
-            return '{}.0'.format(version)
+            return f'{version}.0'
 
         return version
 
@@ -247,7 +247,7 @@ def _get_i18n_statistics(self):
         filename = os.path.join(
             settings.STATIC_DOCS_GEANY_DESTINATION_DIR,
             settings.STATIC_DOCS_GEANY_I18N_STATISTICS_FILENAME)
-        with open(filename) as input_file:
+        with open(filename, encoding='utf-8') as input_file:
             return json.load(input_file)
 
 
@@ -284,7 +284,7 @@ def _get_theme_index(self):
 
         # theme index has been changed remotely?
         if theme_index_md5_hash != cached_theme_index_md5_hash or theme_index is None:
-            logger.debug('Refresh theme index from Github (MD5: {})'.format(theme_index_md5_hash))
+            logger.debug('Refresh theme index from Github (MD5: %s)', theme_index_md5_hash)
             # query whole theme index
             theme_index = self._query_parse_themes_index()
             # cache it for later



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list