Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10027 from mshriver/pre-commit-flake
Browse files Browse the repository at this point in the history
[RFR] Apply pyupgrade
  • Loading branch information
jawatts authored Mar 31, 2020
2 parents 98d1159 + e5755e8 commit f6f0b52
Show file tree
Hide file tree
Showing 480 changed files with 2,150 additions and 2,168 deletions.
21 changes: 12 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ repos:
args: [--safe, --line-length, '100']
language_version: python3.7
<<: *exclude
- repo: https://github.com/asottile/pyupgrade
rev: v1.23.0
hooks:
- id: pyupgrade
language_version: python3.7
args: [--py36-plus]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
language_version: python3.7
additional_dependencies: [polarion-docstrings, bugzilla-docstrings]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
Expand All @@ -23,12 +35,3 @@ repos:
- id: check-yaml
- id: debug-statements
exclude: ^(sprout|scripts|cfme/fixtures/rdb.py)
- id: flake8
language_version: python3.7
additional_dependencies: [polarion-docstrings, bugzilla-docstrings]
- repo: https://github.com/asottile/pyupgrade
rev: v1.23.0
hooks:
- id: pyupgrade
language_version: python3.7
<<: *exclude
2 changes: 1 addition & 1 deletion artifactor/plugins/filedump.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def filedump(

@ArtifactorBasePlugin.check_configured
def sanitize(self, test_location, test_name, artifacts, words):
test_ident = "{}/{}".format(test_location, test_name)
test_ident = f"{test_location}/{test_name}"
filename = None
try:
for f in artifacts[test_ident]["files"]:
Expand Down
6 changes: 3 additions & 3 deletions artifactor/plugins/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


class Logger(ArtifactorBasePlugin):
class Test(object):
class Test:
def __init__(self, ident):
self.ident = ident
self.in_progress = False
Expand All @@ -43,15 +43,15 @@ def configure(self):
def start_test(self, artifact_path, test_name, test_location, slaveid):
if not slaveid:
slaveid = "Master"
test_ident = "{}/{}".format(test_location, test_name)
test_ident = f"{test_location}/{test_name}"
if slaveid in self.store:
if self.store[slaveid].in_progress:
print("Test already running, can't start another, logger")
return None
self.store[slaveid].close()
self.store[slaveid] = self.Test(test_ident)
self.store[slaveid].in_progress = True
filename = "{ident}-cfme.log".format(ident=self.ident)
filename = f"{self.ident}-cfme.log"
self.store[slaveid].handler = make_file_handler(
filename,
root=artifact_path,
Expand Down
2 changes: 1 addition & 1 deletion artifactor/plugins/ostriz.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def ostriz_send(
env_params=None,
):
env_params = env_params or {}
test_ident = "{}/{}".format(test_location, test_name)
test_ident = f"{test_location}/{test_name}"
json_data = artifacts[test_ident]
json_data["name"] = test_ident
json_data["run"] = run_id
Expand Down
20 changes: 9 additions & 11 deletions artifactor/plugins/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def overall_test_status(statuses):
return "passed"


class ReporterBase(object):
class ReporterBase:
def _run_report(self, old_artifacts, artifact_dir, version=None, fw_version=None):
template_data = self.process_data(old_artifacts, artifact_dir, version, fw_version)

Expand All @@ -71,7 +71,7 @@ def render_report(self, report, filename, log_dir, template):
template_env = Environment(loader=FileSystemLoader(template_path.strpath))
data = template_env.get_template(template).render(**report)

with open(os.path.join(log_dir, "{}.html".format(filename)), "w") as f:
with open(os.path.join(log_dir, f"{filename}.html"), "w") as f:
f.write(data)
try:
shutil.copytree(template_path.join("dist").strpath, os.path.join(log_dir, "dist"))
Expand Down Expand Up @@ -201,9 +201,7 @@ def process_data(self, artifacts, log_dir, version, fw_version, name_filter=None

if name_filter:
template_data["tests"] = [
x
for x in template_data["tests"]
if re.findall(r"{}[-\]]+".format(name_filter), x["name"])
x for x in template_data["tests"] if re.findall(fr"{name_filter}[-\]]+", x["name"])
]

# Create the tree dict that is used for js tree
Expand Down Expand Up @@ -295,7 +293,7 @@ def build_li(self, lev):
).format(v["name"], proc_name, teststring, label, pretty_time)
# Do we really need the os.path.split (now process_pytest_path) here?
# For me it seems the name is always the leaf
list_string += "<li>{}</li>\n".format(link)
list_string += f"<li>{link}</li>\n"

# If there is a '_sub' attribute then we know we have other modules to go.
elif "_sub" in v:
Expand Down Expand Up @@ -351,7 +349,7 @@ def composite_pump(self, old_artifacts):

@ArtifactorBasePlugin.check_configured
def skip_test(self, test_location, test_name, skip_data):
test_ident = "{}/{}".format(test_location, test_name)
test_ident = f"{test_location}/{test_name}"
return None, {"artifacts": {test_ident: {"skipped": skip_data}}}

@ArtifactorBasePlugin.check_configured
Expand All @@ -367,7 +365,7 @@ def start_test(
):
if not param_dict:
param_dict = {}
test_ident = "{}/{}".format(test_location, test_name)
test_ident = f"{test_location}/{test_name}"
return (
None,
{
Expand All @@ -388,7 +386,7 @@ def start_test(

@ArtifactorBasePlugin.check_configured
def finish_test(self, artifacts, test_location, test_name, slaveid):
test_ident = "{}/{}".format(test_location, test_name)
test_ident = f"{test_location}/{test_name}"
overall_status = overall_test_status(artifacts[test_ident]["statuses"])
return (
None,
Expand All @@ -414,7 +412,7 @@ def report_test(
test_outcome,
test_phase_duration,
):
test_ident = "{}/{}".format(test_location, test_name)
test_ident = f"{test_location}/{test_name}"
ret_dict = {
"artifacts": {
test_ident: {
Expand All @@ -434,7 +432,7 @@ def session_info(self, version=None, build=None, stream=None, fw_version=None):

@ArtifactorBasePlugin.check_configured
def tb_info(self, test_location, test_name, exception, file_line, short_tb):
test_ident = "{}/{}".format(test_location, test_name)
test_ident = f"{test_location}/{test_name}"
return (
None,
{
Expand Down
6 changes: 3 additions & 3 deletions artifactor/plugins/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


class Video(ArtifactorBasePlugin):
class Test(object):
class Test:
def __init__(self, ident):
self.ident = ident
self.in_progress = False
Expand All @@ -38,7 +38,7 @@ def configure(self):

@ArtifactorBasePlugin.check_configured
def start_test(self, artifact_path, test_name, test_location, slaveid):
test_ident = "{}/{}".format(test_location, test_name)
test_ident = f"{test_location}/{test_name}"
if test_ident in self.tests:
if self.tests[test_ident].in_progress:
print("Test already running, can't start another")
Expand Down Expand Up @@ -78,7 +78,7 @@ def start_test(self, artifact_path, test_name, test_location, slaveid):
@ArtifactorBasePlugin.check_configured
def finish_test(self, artifact_path, test_name, test_location):
"""Finish test"""
test_ident = "{}/{}".format(test_location, test_name)
test_ident = f"{test_location}/{test_name}"
try:
self.tests[test_ident].recorder.stop()
except Exception as e:
Expand Down
8 changes: 4 additions & 4 deletions cfme/ansible/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class Credential(BaseEntity, Taggable):
# is also problematic for attrs

def __init__(self, collection, name, credential_type, **credentials):
super(Credential, self).__init__(collection)
super().__init__(collection)
self.name = name
self.credential_type = credential_type
for key, value in credentials.items():
Expand Down Expand Up @@ -431,7 +431,7 @@ def update(self, updates):
updates.get("name", self.name)))
else:
view.flash.assert_message(
'Edit of Credential "{}" was canceled by the user.'.format(self.name))
f'Edit of Credential "{self.name}" was canceled by the user.')

def delete(self):
view = navigate_to(self, "Details")
Expand All @@ -441,7 +441,7 @@ def delete(self):
wait_for(lambda: False, silent_failure=True, timeout=5)
assert credentials_list_page.is_displayed
credentials_list_page.flash.assert_success_message(
'Deletion of Credential "{}" was successfully initiated.'.format(self.name))
f'Deletion of Credential "{self.name}" was successfully initiated.')
wait_for(
lambda: not self.exists,
delay=10,
Expand Down Expand Up @@ -479,7 +479,7 @@ def create(self, name, credential_type, **credentials):
wait_for(lambda: False, silent_failure=True, timeout=5)
assert credentials_list_page.is_displayed
credentials_list_page.flash.assert_success_message(
'Add of Credential "{}" has been successfully queued.'.format(name))
f'Add of Credential "{name}" has been successfully queued.')

credential = self.instantiate(name, credential_type, **credentials)

Expand Down
6 changes: 3 additions & 3 deletions cfme/ansible/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _wait_until_changes_applied():
wait_for(_wait_until_changes_applied, delay=10, timeout="5m")
else:
view.flash.assert_message(
'Edit of Repository "{}" cancelled by the user.'.format(self.name))
f'Edit of Repository "{self.name}" cancelled by the user.')

def delete(self):
"""Delete the repository in the UI."""
Expand All @@ -227,7 +227,7 @@ def delete(self):
assert repo_list_page.is_displayed
repo_list_page.flash.assert_no_error()
repo_list_page.flash.assert_message(
'Delete of Repository "{}" was successfully initiated.'.format(self.name))
f'Delete of Repository "{self.name}" was successfully initiated.')
wait_for(
lambda: not self.exists,
delay=10,
Expand Down Expand Up @@ -353,7 +353,7 @@ def delete(self, *repositories):
view.flash.assert_no_error()
for repository in checked_repositories:
view.flash.assert_message(
'Delete of Repository "{}" was successfully initiated.'.format(repository.name))
f'Delete of Repository "{repository.name}" was successfully initiated.')


@navigator.register(RepositoryCollection, 'All')
Expand Down
2 changes: 1 addition & 1 deletion cfme/ansible_tower/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def step(self, *args, **kwargs):
try:
row = self.prerequisite_view.entities.get_entity(name=self.obj.name, surf_pages=True)
except ItemNotFound:
raise ItemNotFound('Could not locate template "{}"'.format(self.obj.name))
raise ItemNotFound(f'Could not locate template "{self.obj.name}"')
row.click()


Expand Down
2 changes: 1 addition & 1 deletion cfme/automate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class EditDialogView(DialogForm):
def is_displayed(self):
return (
self.in_customization and self.service_dialogs.is_opened and
self.title.text == "Editing Dialog {}".format(self.label)
self.title.text == f"Editing Dialog {self.label}"
)


Expand Down
6 changes: 3 additions & 3 deletions cfme/automate/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def simulate(

# Group and User are EVM type objects. workaround for <5.11
target_type = (
"EVM {}".format(self.group.type)
f"EVM {self.group.type}"
if self.group.type in ["Group", "User"] and self.appliance.version < "5.11"
else self.group.type
)
Expand Down Expand Up @@ -644,9 +644,9 @@ def is_displayed(self):
expected_title = '{} Button Group "{}"'.format(obj.type, "Unassigned Buttons")
else:
expected_title = (
'Button Group "{}"'.format(obj.text)
f'Button Group "{obj.text}"'
if self.browser.product_version < "5.11"
else '{} Button Group "{}"'.format(obj.type, obj.text)
else f'{obj.type} Button Group "{obj.text}"'
)

return (
Expand Down
6 changes: 3 additions & 3 deletions cfme/automate/dialogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def is_displayed(self):
expected_title = (
"Automate Customization"
if self.browser.product_version < "5.11"
else 'Editing {} Service Dialog'.format(obj.label)
else f'Editing {obj.label} Service Dialog'
)
return (
self.in_customization
Expand All @@ -89,12 +89,12 @@ class CopyDialogView(DialogForm):
@property
def is_displayed(self):
obj = self.context["object"]
expected_label = 'Copy of {}'.format(obj.label)
expected_label = f'Copy of {obj.label}'

expected_title = (
"Automate Customization"
if self.browser.product_version < "5.11"
else 'Editing {} Service Dialog'.format(obj.label)
else f'Editing {obj.label} Service Dialog'
)
return (
self.in_customization
Expand Down
2 changes: 1 addition & 1 deletion cfme/automate/dialogs/dialog_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EditBoxView(BoxForm):
def is_displayed(self):
return (
self.in_customization and
self.title.text == "Editing Dialog {} [Box Information]".format(self.box_label)
self.title.text == f"Editing Dialog {self.box_label} [Box Information]"
)


Expand Down
2 changes: 1 addition & 1 deletion cfme/automate/dialogs/dialog_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EditTabView(TabForm):
def is_displayed(self):
return (
self.in_customization and
self.title.text == "Editing Dialog {} [Tab Information]".format(self.tab_label)
self.title.text == f"Editing Dialog {self.tab_label} [Tab Information]"
)


Expand Down
2 changes: 1 addition & 1 deletion cfme/automate/dialogs/service_dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def delete(self):
assert view.is_displayed
view.flash.assert_no_error()
view.flash.assert_success_message(
'Dialog "{}": Delete successful'.format(self.label))
f'Dialog "{self.label}": Delete successful')

def copy(self):
view = navigate_to(self, "Copy")
Expand Down
2 changes: 1 addition & 1 deletion cfme/automate/explorer/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CopyViewBase(View):
cancel_button = Button('Cancel')


class Copiable(object):
class Copiable:
# TODO: Namespace!
def copy_to(self, domain, new_name=None, replace=None, cancel=False):
copy_page = navigate_to(self, 'Copy')
Expand Down
Loading

0 comments on commit f6f0b52

Please sign in to comment.