jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/879962 )
Change subject: update syntax with pyupgrade ......................................................................
update syntax with pyupgrade
Change-Id: Id9e51cc688c717f7c9f2c191fb84f05962f0ac64 --- M scripts/category_graph.py M scripts/replicate_wiki.py M pywikibot/scripts/wrapper.py M scripts/clean_sandbox.py M scripts/dataextend.py M scripts/archivebot.py 6 files changed, 16 insertions(+), 8 deletions(-)
Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/scripts/wrapper.py b/pywikibot/scripts/wrapper.py index d996f02..6e64d15 100755 --- a/pywikibot/scripts/wrapper.py +++ b/pywikibot/scripts/wrapper.py @@ -250,7 +250,7 @@ # print the minimal requirement _print_requirements( ['setuptools>=20.8.1'], None, - 'outdated ({})'.format(setuptools.__version__)) + f'outdated ({setuptools.__version__})') return False raise e
@@ -330,7 +330,7 @@ assert 0.0 < config.pwb_cut_off < 1.0, \ 'config.pwb_cut_off must be a float in range [0, 1]'
- error('{} not found! Misspelling?'.format(filename)) + error(f'{filename} not found! Misspelling?')
scripts = {}
diff --git a/scripts/archivebot.py b/scripts/archivebot.py index ec9e4db..e57e547 100755 --- a/scripts/archivebot.py +++ b/scripts/archivebot.py @@ -649,7 +649,7 @@ keep_threads = [] threads_per_archive = defaultdict(list) whys = set() - pywikibot.info('Processing {} threads'.format(len(self.page.threads))) + pywikibot.info(f'Processing {len(self.page.threads)} threads') fields = self.get_params(self.now, 0).keys() # dummy parameters regex = re.compile(r'%(((?:{})))d'.format('|'.join(fields))) stringpattern = regex.sub(r'%\1s', pattern) diff --git a/scripts/category_graph.py b/scripts/category_graph.py index 42cca2d..14f0d1c 100755 --- a/scripts/category_graph.py +++ b/scripts/category_graph.py @@ -41,7 +41,6 @@ # Distributed under the terms of the MIT license. # import argparse -import io from collections import defaultdict
import pywikibot @@ -192,7 +191,7 @@ 'src="https://unpkg.com/panzoom@9.4.0/dist/panzoom.min.js" ' 'query="#graph0" name="pz"></script>\n' '<style> svg { height:100%; width:100%; } </style>\n') - with io.open(self.to + '.html', mode='wb') as o: + with open(self.to + '.html', mode='wb') as o: o.write(header.encode()) o.write(self.dot.create('dot', 'svg', encoding='utf-8'))
diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py index 2beb82b..1cb6f34 100755 --- a/scripts/clean_sandbox.py +++ b/scripts/clean_sandbox.py @@ -307,7 +307,7 @@ "can't be provided at the same time") return try: - with open(textfile_opt, 'r', encoding='utf-8') as textfile: + with open(textfile_opt, encoding='utf-8') as textfile: opts['text'] = textfile.read() except OSError as e: pywikibot.error(f'Error loading {opts["textfile"]}: {e}') diff --git a/scripts/dataextend.py b/scripts/dataextend.py index 713299f..6799f31 100755 --- a/scripts/dataextend.py +++ b/scripts/dataextend.py @@ -455,7 +455,7 @@ for claim in claims[prop]: if claim.type == 'wikibase-item': if claim.getTarget() is None: - pywikibot.info('{}: unknown'.format(self.label(prop))) + pywikibot.info(f'{self.label(prop)}: unknown') else: pywikibot.info( '{}: {}' diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py index 12191e4..f128eee 100755 --- a/scripts/replicate_wiki.py +++ b/scripts/replicate_wiki.py @@ -125,7 +125,7 @@ if self.options.namespace: pywikibot.info(str(self.options.namespace)) namespaces = [int(self.options.namespace)] - pywikibot.info('Checking these namespaces: {}\n'.format((namespaces,))) + pywikibot.info(f'Checking these namespaces: {namespaces}\n')
for ns in namespaces: self.check_namespace(ns)
pywikibot-commits@lists.wikimedia.org