Skip to content

Commit

Permalink
style: ruff minor version upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
vEnhance committed Jan 15, 2025
1 parent fed8806 commit a06270a
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 46 deletions.
2 changes: 1 addition & 1 deletion conky/dijo-today.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
for habit in data:
if today not in habit["stats"] and habit["name"] != "climb":
goal = int(habit.get("goal", 1))
print(f"[{goal}] {habit["name"]}")
print(f"[{goal}] {habit['name']}")
2 changes: 1 addition & 1 deletion conky/prettycal.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def conky_repr(self, offset=None, needs_date=False, truncate=36):
s += r"${voffset -1}${font Exo 2:semibold:size=%d}" % FONT_SIZE
else:
s += r"${font Exo 2:light:size=%d}" % FONT_SIZE
s += f'{self.when.date().strftime("%a %b%d")} '
s += f"{self.when.date().strftime('%a %b%d')} "
if self.type == Type.CALENDAR or self.type == Type.NOW:
s += r"${voffset 1}"
s += r"${font Exo 2:normal:size=%d}" % FONT_SIZE
Expand Down
2 changes: 1 addition & 1 deletion gnucash-txn-import/scrape_paypal.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_child_string(
row_date = datetime.strptime(f"{str_date} {current_year}", r"%b %d %Y").date()
if row_date > _date.today():
row_date = datetime.strptime(
f"{str_date} {current_year-1}", r"%b %d %Y"
f"{str_date} {current_year - 1}", r"%b %d %Y"
).date()
row_description = get_child_string(
div, tag_name="div", class_name="counterparty_name"
Expand Down
10 changes: 5 additions & 5 deletions nerd-dictation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
# Replace Multiple Words

TEXT_REPLACE_REGEX = (
("\\b" "data type" "\\b", "data-type"),
("\\b" "copy on write" "\\b", "copy-on-write"),
("\\b" "key word" "\\b", "keyword"),
("\\b" "paragraph" "\\b", "\r"),
("\\b" "new line" "\\b", "\r"),
("\\bdata type\\b", "data-type"),
("\\bcopy on write\\b", "copy-on-write"),
("\\bkey word\\b", "keyword"),
("\\bparagraph\\b", "\r"),
("\\bnew line\\b", "\r"),
)
TEXT_REPLACE_REGEX = tuple(
(re.compile(match), replacement) for (match, replacement) in TEXT_REPLACE_REGEX
Expand Down
6 changes: 3 additions & 3 deletions py-scripts/export-ggb-clean-asy.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def replace_numbers(s):

if args.no_header is False:
first_line = input_buffer.readline()
assert (
"Geogebra to Asymptote conversion" in first_line
), f"First line is missing header\n{first_line}"
assert "Geogebra to Asymptote conversion" in first_line, (
f"First line is missing header\n{first_line}"
)
# print(r'/* start ggb to asy preamble */', file=output_buffer)

# Preamble
Expand Down
4 changes: 2 additions & 2 deletions py-scripts/latex2wp.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def convertonetable(m, border):

def separatemath(m):
mathre = re.compile(
"\\$.*?\\$" "|\\\\begin\\{equation}.*?\\\\end\\{equation}" "|\\\\\\[.*?\\\\\\]"
"\\$.*?\\$|\\\\begin\\{equation}.*?\\\\end\\{equation}|\\\\\\[.*?\\\\\\]"
)
math = mathre.findall(m)
text = mathre.split(m)
Expand All @@ -298,7 +298,7 @@ def processmath(M):
global ref

mathdelim = re.compile(
"\\$" "|\\\\begin\\{equation}" "|\\\\end\\{equation}" "|\\\\\\[|\\\\\\]"
"\\$|\\\\begin\\{equation}|\\\\end\\{equation}|\\\\\\[|\\\\\\]"
)
label = re.compile("\\\\label\\{.*?}")

Expand Down
6 changes: 3 additions & 3 deletions py-scripts/odus.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def APPLY_COLOR(color_name, s):
d, r, _, source = m.groups()
w = hardness_chart[d]
if detect_missing is False:
assert (
fn not in seen[source] or w == 0
), f"you dummy you duped {source} in {fn}"
assert fn not in seen[source] or w == 0, (
f"you dummy you duped {source} in {fn}"
)
seen[source][fn] = (w, r)
elif detect_missing is True:
seen_set.add(source)
Expand Down
17 changes: 9 additions & 8 deletions py-scripts/oscar.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def get_bottom_cell(n: int, percent: bool):
# textcolor = 'white' if n / N < 0.2 else 'black'

if percent:
content = r"{}^{\%}" + f"{100*r:.1f}"
content = r"{}^{\%}" + f"{100 * r:.1f}"
else:
content = r"\textbf{" + str(n) + "}"

Expand All @@ -180,9 +180,9 @@ def get_bottom_cell(n: int, percent: bool):
continue
data = line.split("\t")
studentscores = [int(x) if (x in "01234567" and x) else 0 for x in data[:-1]]
assert sum(studentscores) == int(
data[-1]
), f"Total doesn't match: {studentscores} != {data[-1]}"
assert sum(studentscores) == int(data[-1]), (
f"Total doesn't match: {studentscores} != {data[-1]}"
)
for i in range(NUM_PROBLEMS):
scores_by_pr[i].append(studentscores[i])

Expand Down Expand Up @@ -343,7 +343,8 @@ def printMP(S0, start, stop):
print(r"\section{Full stats for %s}" % name, file=outfile)
print(r"\begin{longtable}{r|" + "r" * NUM_PROBLEMS + "|r}", file=outfile)
print(
"Rank & " + " & ".join(f"P{i+1}" for i in range(NUM_PROBLEMS)), file=outfile
"Rank & " + " & ".join(f"P{i + 1}" for i in range(NUM_PROBLEMS)),
file=outfile,
)
print(r"& $\Sigma$ \\ \hline \endhead", file=outfile)
for scores in scores_raw:
Expand Down Expand Up @@ -371,9 +372,9 @@ def clean_name(s):

if __name__ == "__main__":
files = args.files
assert len(files) == 1 or (
args.output is None and args.name is None
), "can't write multiple inputs to a single output"
assert len(files) == 1 or (args.output is None and args.name is None), (
"can't write multiple inputs to a single output"
)

if len(files) == 1:
f = files[0]
Expand Down
12 changes: 5 additions & 7 deletions py-scripts/stomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@

if __name__ == "__main__":
if opts.new:
assert (
not main_path.exists()
), "You shouldn't use stomp -n if the file exists already"
assert not main_path.exists(), (
"You shouldn't use stomp -n if the file exists already"
)
(main_path.parent / "tests").mkdir(exist_ok=True)
if PROGRAM_TYPE == "PYTHON":
shutil.copy(TEMPLATE_PATHS / "main.py", main_path)
Expand Down Expand Up @@ -135,8 +135,7 @@
)
if compile_process.returncode != 0:
print(
f"👿 {TERM_COLOR['BOLD_YELLOW']}"
f"COMPILATION FAILED{TERM_COLOR['RESET']}"
f"👿 {TERM_COLOR['BOLD_YELLOW']}COMPILATION FAILED{TERM_COLOR['RESET']}"
)
sys.exit(1)
else:
Expand All @@ -157,8 +156,7 @@
)
if compile_process.returncode != 0:
print(
f"👿 {TERM_COLOR['BOLD_YELLOW']}"
f"COMPILATION FAILED{TERM_COLOR['RESET']}"
f"👿 {TERM_COLOR['BOLD_YELLOW']}COMPILATION FAILED{TERM_COLOR['RESET']}"
)
sys.exit(1)
else:
Expand Down
2 changes: 1 addition & 1 deletion py-scripts/tsqx.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def generate_points(kind, n) -> list[str]:
if kind == "triangle":
return ["dir(110)", "dir(210)", "dir(330)"]
elif kind == "regular":
return [f"dir({(90 + i*360/n) % 360})" for i in range(n)]
return [f"dir({(90 + i * 360 / n) % 360})" for i in range(n)]
raise SyntaxError("Special command not recognized")


Expand Down
8 changes: 4 additions & 4 deletions py-scripts/yao.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,21 @@ def generate_key_pair(bits):
opts.salary
if opts.salary is not None
else getpass.getpass(
f"You are Alice. What's your salary? (Input hidden, 0-{MAX-1}) "
f"You are Alice. What's your salary? (Input hidden, 0-{MAX - 1}) "
)
)
SJ = None
assert 0 <= SI < MAX, f"Out of range. Must be between 0 and {MAX-1}"
assert 0 <= SI < MAX, f"Out of range. Must be between 0 and {MAX - 1}"
else:
SI = None
SJ = int(
opts.salary
if opts.salary is not None
else getpass.getpass(
f"You are Bob. What's your salary? (Input hidden, 0-{MAX-1}) "
f"You are Bob. What's your salary? (Input hidden, 0-{MAX - 1}) "
)
)
assert 0 <= SJ < MAX, f"Out of range. Must be between 0 and {MAX-1}"
assert 0 <= SJ < MAX, f"Out of range. Must be between 0 and {MAX - 1}"

if opts.alice is True:
if Path(KEY_FILENAME).exists():
Expand Down
6 changes: 3 additions & 3 deletions ranger/commands_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ def execute(self):
if not mode_str:
if self.quantifier is None:
self.fm.notify(
"Syntax: chmod <octal number> " "or specify a quantifier", bad=True
"Syntax: chmod <octal number> or specify a quantifier", bad=True
)
return
mode_str = str(self.quantifier)
Expand Down Expand Up @@ -1229,10 +1229,10 @@ def execute(self):
with tempfile.NamedTemporaryFile() as cmdfile:
script_lines = []
script_lines.append(
"# This file will be executed when you close" " the editor."
"# This file will be executed when you close the editor."
)
script_lines.append(
"# Please double-check everything, clear the" " file to abort."
"# Please double-check everything, clear the file to abort."
)
new_dirs = []
for old, new in zip(filenames, new_filenames):
Expand Down
8 changes: 3 additions & 5 deletions venueQ/otis.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def get_path(self, ext: Optional[str] = None):
assert self.ext is not None
ext = self.ext
assert ext in ProblemSet.EXTENSIONS, f"{ext} is not a valid extension"
fname = f'otis_{self.data["pk"]:06d}'
fname = f"otis_{self.data['pk']:06d}"
fname += "_"
fname += self.data["name"].replace(" ", "_")
fname += "_"
Expand Down Expand Up @@ -245,7 +245,7 @@ def init_hook(self):

# collect data about the handout
if HANDOUTS_PATH.exists():
filename = f'**/{data["unit__code"]}-{data["unit__group__slug"]}.tex'
filename = f"**/{data['unit__code']}-{data['unit__group__slug']}.tex"
handouts = list(HANDOUTS_PATH.glob(filename))
assert len(handouts) == 1
total = 0
Expand All @@ -269,9 +269,7 @@ def init_hook(self):
w = ProblemSet.HARDNESS_CHART[d]
total += w
num_problems += 1
data["clubs_max"] = (
f"max {1+total} | " f"hi {high_clubs} | " f"min {min_clubs}"
)
data["clubs_max"] = f"max {1 + total} | hi {high_clubs} | min {min_clubs}"
else:
data["clubs_max"] = None
total = None
Expand Down
3 changes: 1 addition & 2 deletions venueQ/venueQ.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ def wipe(self):
vim.command(f"bdelete! {bn}")
except vim.error:
logging.warn(
f"Could not delete buffer {bn}, "
"maybe it was deleted already."
f"Could not delete buffer {bn}, maybe it was deleted already."
)
self.wipe_queue = []

0 comments on commit a06270a

Please sign in to comment.