Skip to content

Commit

Permalink
formatting fixes
Browse files Browse the repository at this point in the history
I assume ruff's updated a few things since last time it was run, as it
now fails.
  • Loading branch information
masklinn committed Feb 1, 2025
1 parent 9f170aa commit 5f5f338
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
6 changes: 3 additions & 3 deletions src/ua_parser/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def run_stdout(args: argparse.Namespace) -> None:
lines = list(args.file)
count = len(lines)
uniques = len(set(lines))
print(f"{args.file.name}: {count} lines, {uniques} unique ({uniques/count:.0%})")
print(f"{args.file.name}: {count} lines, {uniques} unique ({uniques / count:.0%})")

rules = get_rules(args.bases, args.regexes)

Expand Down Expand Up @@ -320,7 +320,7 @@ def belady(maxsize: int) -> Cache:
overhead / cache_size,
)
print(
f"{cache.__name__.lower():8}({cache_size:{w}}): {(total - misses.count)/total*100:2.0f}% hit rate {diff}"
f"{cache.__name__.lower():8}({cache_size:{w}}): {(total - misses.count) / total * 100:2.0f}% hit rate {diff}"
)
del misses, parser

Expand Down Expand Up @@ -378,7 +378,7 @@ def run_threaded(args: argparse.Namespace) -> None:
totlines = len(lines) * args.threads
# runtime in us
t = (time.perf_counter_ns() - st) / 1000
print(f"{t/totlines:>4.0f}us/line", flush=True)
print(f"{t / totlines:>4.0f}us/line", flush=True)


EPILOG = """For good results the sample `file` should be an actual
Expand Down
72 changes: 36 additions & 36 deletions tests/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ def runUserAgentTestsFromYAML(self, file_name):

result = {}
result = user_agent_parser.ParseUserAgent(user_agent_string)
assert (
result == expected
), "UA: {0}\n expected<{1}, {2}, {3}, {4}> != actual<{5}, {6}, {7}, {8}>".format(
user_agent_string,
expected["family"],
expected["major"],
expected["minor"],
expected["patch"],
result["family"],
result["major"],
result["minor"],
result["patch"],
assert result == expected, (
"UA: {0}\n expected<{1}, {2}, {3}, {4}> != actual<{5}, {6}, {7}, {8}>".format(
user_agent_string,
expected["family"],
expected["major"],
expected["minor"],
expected["patch"],
result["family"],
result["major"],
result["minor"],
result["patch"],
)
)
assert (
len(user_agent_parser._PARSE_CACHE) <= user_agent_parser.MAX_CACHE_SIZE
Expand All @@ -143,20 +143,20 @@ def runOSTestsFromYAML(self, file_name):
}

result = user_agent_parser.ParseOS(user_agent_string)
assert (
result == expected
), "UA: {0}\n expected<{1} {2} {3} {4} {5}> != actual<{6} {7} {8} {9} {10}>".format(
user_agent_string,
expected["family"],
expected["major"],
expected["minor"],
expected["patch"],
expected["patch_minor"],
result["family"],
result["major"],
result["minor"],
result["patch"],
result["patch_minor"],
assert result == expected, (
"UA: {0}\n expected<{1} {2} {3} {4} {5}> != actual<{6} {7} {8} {9} {10}>".format(
user_agent_string,
expected["family"],
expected["major"],
expected["minor"],
expected["patch"],
expected["patch_minor"],
result["family"],
result["major"],
result["minor"],
result["patch"],
result["patch_minor"],
)
)

def runDeviceTestsFromYAML(self, file_name):
Expand All @@ -176,16 +176,16 @@ def runDeviceTestsFromYAML(self, file_name):
}

result = user_agent_parser.ParseDevice(user_agent_string)
assert (
result == expected
), "UA: {0}\n expected<{1} {2} {3}> != actual<{4} {5} {6}>".format(
user_agent_string,
expected["family"],
expected["brand"],
expected["model"],
result["family"],
result["brand"],
result["model"],
assert result == expected, (
"UA: {0}\n expected<{1} {2} {3}> != actual<{4} {5} {6}>".format(
user_agent_string,
expected["family"],
expected["brand"],
expected["model"],
result["family"],
result["brand"],
result["model"],
)
)


Expand Down

0 comments on commit 5f5f338

Please sign in to comment.