Skip to content

Commit d9c530d

Browse files
committed
Fix formatting with ruff
1 parent b6ee481 commit d9c530d

37 files changed

Lines changed: 96 additions & 113 deletions

‎docs/buildsystem.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class MyFirstBuilder(PdfBuilder):
368368
"""
369369
A really simple builder implementation
370370
"""
371-
371+
372372
name = "My First Builder"
373373
"""
374374
Display name to use to refer to this builder in build output panel.
@@ -391,9 +391,9 @@ class MyFirstBuilder(PdfBuilder):
391391
# 2. message to display when command is executed
392392
#
393393
# It should describe the executed program and end with "..."
394-
# to indicate progress.
394+
# to indicate progress.
395395
#
396-
# The back-end will append "done", "error", "cancelled" status,
396+
# The back-end will append "done", "error", "cancelled" status,
397397
# after command execution finished.
398398
yield ("pdflatex", "running pdflatex...")
399399
```
@@ -503,6 +503,7 @@ class SimpleBuilder(PdfBuilder):
503503
504504
Just call a bunch of commands in sequence to demonstrate basics
505505
"""
506+
506507
name = "Simple Builder"
507508

508509
def commands(self) -> CommandGenerator:

‎latextools/auto_label.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ def run(self, edit):
124124
snippet = (
125125
f"{before_text}" # leading \label{
126126
f"${{1:{label_type}}}:${{2:{label_content}}}"
127-
f"{after_text}" # trailing }
127+
f"{after_text}" # trailing }
128128
"$0"
129129
)
130130
view.run_command("insert_snippet", {"contents": snippet})
131131
else:
132132
content = (
133133
f"{before_text}" # leading \label{
134134
f"{label_type}:{label_content}"
135-
f"{after_text}" # trailing }
135+
f"{after_text}" # trailing }
136136
)
137137
view.insert(edit, pos, content)
138138

‎latextools/biblatex_crossref_completions.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ def get_completions_if_matches(regex, line, get_key_list_func, view):
120120

121121
completions = [
122122
sublime.CompletionItem(
123-
trigger=name,
124-
completion=_get_replacement(matcher, name),
125-
kind=KIND_INFO
123+
trigger=name, completion=_get_replacement(matcher, name), kind=KIND_INFO
126124
)
127125
for name in get_key_list_func(view)
128126
]

‎latextools/biblatex_name_completions.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def _get_replacement(matcher, key):
4242
return "{}{1}{}".format(
4343
"" if equals else "= " if match.startswith(" ") else " = ",
4444
"" if matcher.group("OPEN") else "{" if not equals or match.startswith(" ") else " {",
45-
)
45+
)
4646

4747
if matcher.group("ENTRIES").startswith("dna"):
4848
if match.startswith(" "):

‎latextools/context_provider.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ def _inside_envs(self, view, pos, envs):
159159
env.endswith("*"): r"\*",
160160
}.get(True, r"\*?")
161161
env = env.rstrip("*!")
162-
benv = fr"\\begin(?:\[[^\]]\])?{{{env}{star}}}"
163-
eenv = fr"\\end{{{env}{star}}}"
162+
benv = rf"\\begin(?:\[[^\]]\])?{{{env}{star}}}"
163+
eenv = rf"\\end{{{env}{star}}}"
164164

165165
if only_nearest:
166166
real_benv = benv
@@ -215,9 +215,7 @@ def _inside_coms(self, view, pos, coms):
215215
while text:
216216
try:
217217
command_match = next(
218-
c
219-
for c in command_re.finditer(text)
220-
if c.start() < text_pos < c.end()
218+
c for c in command_re.finditer(text) if c.start() < text_pos < c.end()
221219
)
222220
except StopIteration:
223221
break

‎latextools/jumpto_anywhere.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _get_selected_arg(view, com_reg, pos):
3838

3939
if cursor < 0 or len(args) < cursor:
4040
# need to explicit select the argument
41-
message = "Selection to vague. Directly click on the name" " inside the command."
41+
message = "Selection to vague. Directly click on the name inside the command."
4242
logger.error(message)
4343
sublime.status_message(message)
4444
return
@@ -308,8 +308,8 @@ def is_inside(g):
308308
{
309309
"auto_create_missing_folders": False,
310310
"auto_insert_root": False,
311-
"position": position
312-
}
311+
"position": position,
312+
},
313313
)
314314
elif command in ["usepackage", "Requirepackage"]:
315315
_jumpto_pkg_doc(view, com_reg, pos)

‎latextools/jumpto_pdf.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ def get_viewer():
4646
viewer = get_plugin(viewer_name)
4747
except NoSuchPluginException:
4848
sublime.error_message(
49-
f"Cannot find viewer {viewer_name}.\n"
50-
"Please check your LaTeXTools Preferences."
49+
f"Cannot find viewer {viewer_name}.\nPlease check your LaTeXTools Preferences."
5150
)
5251
raise NoViewerException()
5352

@@ -69,7 +68,6 @@ def get_viewer():
6968
# Jump to current row in PDF file
7069
# NOTE: must be called with {"from_keybinding": <boolean>} as arg
7170
class LatextoolsJumptoPdfCommand(sublime_plugin.WindowCommand):
72-
7371
def is_visible(self):
7472
view = self.window.active_view()
7573
return view and view.match_selector(0, "text.tex")
@@ -102,12 +100,14 @@ def run(self, **args):
102100
if from_keybinding:
103101
forward_sync = True
104102

105-
logger.debug(f"from_keybinding={from_keybinding}, keep_focus={keep_focus}, forward_sync={forward_sync}")
103+
logger.debug(
104+
f"from_keybinding={from_keybinding}, keep_focus={keep_focus}, forward_sync={forward_sync}"
105+
)
106106

107107
file_name = view.file_name()
108108
if not is_tex_file(file_name):
109109
if from_keybinding:
110-
file_name = os.path.basename(file_name) if file_name else 'untitled'
110+
file_name = os.path.basename(file_name) if file_name else "untitled"
111111
sublime.error_message(f"{file_name} is not a TeX source file: cannot jump.")
112112
return
113113
# If not invoked from keybinding, it is invoked by the
@@ -188,7 +188,6 @@ def run(self, **args):
188188

189189

190190
class LatextoolsViewPdfCommand(sublime_plugin.WindowCommand):
191-
192191
def is_visible(self, *args):
193192
view = self.window.active_view()
194193
return view and view.match_selector(0, "text.tex")

‎latextools/jumpto_tex_file.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
__all__ = ["LatextoolsJumptoFileCommand"]
1616

17-
INPUT_REG = re.compile(
18-
r"\\(?:input|include|subfile|loadglsentries)\{(?P<file>[^}]+)\}", re.UNICODE
19-
)
17+
INPUT_REG = re.compile(r"\\(?:input|include|subfile|loadglsentries)\{(?P<file>[^}]+)\}", re.UNICODE)
2018

2119
IMPORT_REG = re.compile(
2220
r"\\(?:(?:sub)?import|(?:sub)?inputfrom|(?:sub)?includefrom)"
@@ -34,8 +32,7 @@
3432
)
3533

3634
IMAGE_REG = re.compile(
37-
r"\\includegraphics(?:<[^>]*>)?(?:\[[^\]]*\])?\{(?P<file>[^\}]+)\}"
38-
, re.UNICODE
35+
r"\\includegraphics(?:<[^>]*>)?(?:\[[^\]]*\])?\{(?P<file>[^\}]+)\}", re.UNICODE
3936
)
4037

4138

@@ -220,7 +217,6 @@ def _split_bib_args(bib_args):
220217

221218

222219
class LatextoolsJumptoFileCommand(sublime_plugin.TextCommand):
223-
224220
def run(self, edit, auto_create_missing_folders=True, auto_insert_root=True, position=None):
225221
view = self.view
226222
tex_root = get_tex_root(view)

‎latextools/latex_cite_completions.py‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,7 @@ def kpsewhich(filename, file_format=None):
202202
if e.output:
203203
logger.debug(e.output)
204204
except OSError as e:
205-
logger.error(
206-
"Could not run kpsewhich. Please ensure that your texpath " "setting is correct."
207-
)
205+
logger.error("Could not run kpsewhich. Please ensure that your texpath setting is correct.")
208206
logger.debug(e)
209207

210208
return None
@@ -409,8 +407,7 @@ def _run_command(plugin_name):
409407

410408
if expect_result and result is None:
411409
raise BibPluginError(
412-
f"Could not find a plugin to handle '{command}'. "
413-
"See the console for more details"
410+
f"Could not find a plugin to handle '{command}'. See the console for more details"
414411
)
415412

416413
return result
@@ -522,9 +519,7 @@ def get_completions(self, view, prefix, line):
522519
display = []
523520
values = []
524521

525-
panel_format = get_setting(
526-
"cite_panel_format", ["{title} ({keyword})", "{author}"], view
527-
)
522+
panel_format = get_setting("cite_panel_format", ["{title} ({keyword})", "{author}"], view)
528523
kind = (sublime.KIND_ID_TYPE, "b", "Bibliography")
529524

530525
for c in completions:

‎latextools/latex_command_completions.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_own_xparse_commands(ana):
7272
"RenewExpandableDocumentCommand",
7373
"ProvideExpandableDocumentCommand",
7474
],
75-
flags=analysis.NO_BEGIN_END_COMMANDS
75+
flags=analysis.NO_BEGIN_END_COMMANDS,
7676
)
7777

7878

@@ -123,7 +123,7 @@ def get_own_command_completions(tex_root):
123123
trigger=f"{c.args}{{{c.args2 or ''}}}",
124124
completion=c.args,
125125
annotation="local",
126-
details = f"from {os.path.basename(c.file_name)}",
126+
details=f"from {os.path.basename(c.file_name)}",
127127
kind=kind,
128128
)
129129
)

0 commit comments

Comments
 (0)