summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2022-07-24 17:00:10 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2022-07-31 13:29:20 -0700
commit549ba1ed32372c67fc57271cde3797d58b7dec6e (patch)
tree04ce5f7d2c3b4407b76ecb1f865d237aa7880bae /share
parent156af2a60ab61bb8c03fbe23a52d8ee25c504b23 (diff)
downloadspack-549ba1ed32372c67fc57271cde3797d58b7dec6e.tar.gz
spack-549ba1ed32372c67fc57271cde3797d58b7dec6e.tar.bz2
spack-549ba1ed32372c67fc57271cde3797d58b7dec6e.tar.xz
spack-549ba1ed32372c67fc57271cde3797d58b7dec6e.zip
black: fix style check package and flake8 formatting for black
Black will automatically fix a lot of the exceptions we previously allowed for directives, so we don't need them in our custom `flake8_formatter` anymore. - [x] remove `E501` (long line) exceptions for directives from `flake8_formatter`, as they won't help us now. - [x] Refine exceptions for long URLs in the `flake8_formatter`. - [x] Adjust the mock `flake8-package` to exhibit the exceptions we still allow. - [x] Update style tests for new `flake8-package`. - [x] Blacken style test.
Diffstat (limited to 'share')
-rw-r--r--share/spack/qa/flake8_formatter.py39
1 files changed, 5 insertions, 34 deletions
diff --git a/share/spack/qa/flake8_formatter.py b/share/spack/qa/flake8_formatter.py
index 523ee7b4d0..93cb4cf3fb 100644
--- a/share/spack/qa/flake8_formatter.py
+++ b/share/spack/qa/flake8_formatter.py
@@ -21,24 +21,6 @@ pattern_exemptions = {
r"^from spack.package import \*$",
r"^from spack.package_defs import \*$",
],
- # Exempt lines with urls and descriptions from overlong line errors.
- "E501": [
- r"^\s*homepage\s*=",
- r"^\s*url\s*=",
- r"^\s*git\s*=",
- r"^\s*svn\s*=",
- r"^\s*hg\s*=",
- r"^\s*pypi\s*=",
- r"^\s*list_url\s*=",
- r"^\s*version\(",
- r"^\s*variant\(",
- r"^\s*provides\(",
- r"^\s*extends\(",
- r"^\s*depends_on\(",
- r"^\s*conflicts\(",
- r"^\s*resource\(",
- r"^\s*patch\(",
- ],
# Exempt '@when' decorated functions from redefinition errors.
"F811": [
r"^\s*@when\(.*\)",
@@ -47,7 +29,7 @@ pattern_exemptions = {
# exemptions applied to all files.
r".py$": {
"E501": [
- r"(https?|ftp|file)\:", # URLs
+ r"(ssh|https?|ftp|file)\:", # URLs
r'([\'"])[0-9a-fA-F]{32,}\1', # long hex checksums
]
},
@@ -58,10 +40,7 @@ pattern_exemptions = {
pattern_exemptions = dict(
(
re.compile(file_pattern),
- dict(
- (code, [re.compile(p) for p in patterns])
- for code, patterns in error_dict.items()
- ),
+ dict((code, [re.compile(p) for p in patterns]) for code, patterns in error_dict.items()),
)
for file_pattern, error_dict in pattern_exemptions.items()
)
@@ -105,9 +84,7 @@ class SpackFormatter(Pylint):
# get list of patterns for this error code
pats = self.spack_errors.get(error.code, None)
# if any pattern matches, skip line
- if pats is not None and any(
- (pat.search(error.physical_line) for pat in pats)
- ):
+ if pats is not None and any((pat.search(error.physical_line) for pat in pats)):
return
# Special F811 handling
@@ -117,16 +94,10 @@ class SpackFormatter(Pylint):
# https://gitlab.com/pycqa/flake8/issues/583
# we can only determine if F811 should be ignored given the previous
# line, so get the previous line and check it
- if (
- self.spack_errors.get("F811", False)
- and error.code == "F811"
- and error.line_number > 1
- ):
+ if self.spack_errors.get("F811", False) and error.code == "F811" and error.line_number > 1:
if self.file_lines is None:
if self.filename in {"stdin", "-", "(none)", None}:
- self.file_lines = pycodestyle.stdin_get_value().splitlines(
- True
- )
+ self.file_lines = pycodestyle.stdin_get_value().splitlines(True)
else:
self.file_lines = pycodestyle.readlines(self.filename)
for pat in self.spack_errors["F811"]: