Skip to content

Commit

Permalink
Make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
mnot committed Dec 9, 2023
1 parent fbc38bb commit d38cf15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
16 changes: 6 additions & 10 deletions httplint/field/parsers/cache_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ def evaluate(self, add_note: AddNoteMethodType) -> None:
if self.message.message_type == "response":
for directive, potential_conflicts in CONFLICTING_CC:
if directive in cc_list:
conflicts = list(set(cc_list).intersection(set(potential_conflicts)))
conflicts = list(
set(cc_list).intersection(set(potential_conflicts))
)
if len(conflicts) > 0:
add_note(
CC_CONFLICTING,
Expand Down Expand Up @@ -231,9 +233,7 @@ class CC_CONFLICTING(Note):
class CC_WRONG_MESSAGE(Note):
category = categories.CACHING
level = levels.WARN
_summary = (
"The %(directive)s cache directive has no meaning in a %(message)s."
)
_summary = "The %(directive)s cache directive has no meaning in a %(message)s."
_text = """\
The `%(directive)s` cache directive is only defined to appear in %(other_message)s
messages; is has no defined meaning in a %(message)s."""
Expand All @@ -242,9 +242,7 @@ class CC_WRONG_MESSAGE(Note):
class CHECK_SINGLE(Note):
category = categories.CACHING
level = levels.WARN
_summary = (
"Only one of the pre-check and post-check cache directives is present."
)
_summary = "Only one of the pre-check and post-check cache directives is present."
_text = """\
Microsoft Internet Explorer implements two `Cache-Control` extensions, `pre-check` and
`post-check`, to give more control over how its cache stores responses.
Expand Down Expand Up @@ -276,9 +274,7 @@ class CHECK_ALL_ZERO(Note):
class CHECK_POST_BIGGER(Note):
category = categories.CACHING
level = levels.WARN
_summary = (
"The post-check cache directive's value is larger than pre-check's."
)
_summary = "The post-check cache directive's value is larger than pre-check's."
_text = """\
Microsoft Internet Explorer implements two `Cache-Control` extensions, `pre-check` and
`post-check`, to give more control over how its cache stores responses.
Expand Down
12 changes: 7 additions & 5 deletions httplint/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,21 @@ def display_bytes(inbytes: bytes, encoding: str = "utf-8", truncate: int = 40) -
return "".join(out)


def prose_list(inlist: List[str], markup:str = "") -> str:
def prose_list(inlist: List[str], markup: str = "") -> str:
"""
Format a list of strings into prose.
"""
length = len(inlist)
m = markup
mu = markup
if length == 0:
return "(none)"
if length == 1:
return f"{m}{inlist[0]}{m}"
return f"{mu}{inlist[0]}{mu}"
if length == 2:
return f"{m}{inlist[0]}{m} and {m}{inlist[1]}{m}"
return f"{', '.join([f'{m}{i}{m}' for i in inlist[:-1]])}, and {m}{inlist[-1]}{m}"
return f"{mu}{inlist[0]}{mu} and {mu}{inlist[1]}{mu}"
return (
f"{', '.join([f'{mu}{i}{mu}' for i in inlist[:-1]])}, and {mu}{inlist[-1]}{mu}"
)


def relative_time(utime: float, now: float = None, show_sign: int = 1) -> str:
Expand Down

0 comments on commit d38cf15

Please sign in to comment.