Skip to content

Commit 0512333

Browse files
author
Gunther Klessinger
committed
fmt: black->ruff. format run by ruff.
1 parent 96a0dc3 commit 0512333

46 files changed

Lines changed: 591 additions & 595 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

justfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ test-cov:
2828
uv run coverage combine
2929
uv run coverage report --precision=2
3030

31-
# Format code with black
31+
# Format code with ruff
3232
format:
33-
uv run black src tests
34-
uv run isort src tests
33+
uv run ruff format src tests
34+
uv run ruff check --fix src tests
3535

3636
# Run type checking
3737
typecheck:
3838
uv run mypy src
3939

4040
# Lint code
4141
lint:
42-
uv run flake8 src tests
42+
uv run ruff check src tests
4343

4444
# Run all quality checks (format, lint, typecheck)
4545
check: format lint typecheck

src/lcdoc/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
44
Documentation tools for lc projects
55
"""
6-
import os, sys
6+
7+
import os
8+
import sys
79

810
# for apps on gevent we must patch early => Set that env variable:
911
# (see docs lp tips.md)

src/lcdoc/call_flows/auto_docs.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import os, sys, socket, time
1+
import os
2+
import sys
3+
import socket
4+
import time
25
import inspect
36
from lcdoc.call_flows import markdown as MD
47
from lcdoc.tools import write_file, read_file, exists
@@ -7,7 +10,7 @@
710
h = lambda level, s: '#' * level + ' ' + s
811
source = inspect.getsource
912

10-
auto_gen_cmt = '''
13+
auto_gen_cmt = """
1114
<!-- AUTOMATICALLY GENERATED FILE - DO NOT DIRECTLY EDIT!
1215
1316
Direct edits will be gone after next CI build.
@@ -16,7 +19,7 @@
1619
1720
%s
1821
-->
19-
'''
22+
"""
2023

2124

2225
def mark_auto_created(fn):
@@ -119,7 +122,6 @@ def filt(f):
119122

120123

121124
def mod_doc(mod, dest='auto'):
122-
123125
from lcdoc.call_flows.call_flow_logging import autodoc_dir
124126

125127
d = autodoc_dir(mod, dest)

src/lcdoc/call_flows/call_flow_charting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def href(s, tooltip, nr, typ, viz=viz, max_tooltip_len=3000):
111111
if inp:
112112
if t0 > time_:
113113
# r_add('d <-> t: %s' viz.req('d', 't', what=str(round(time_, rnd))))
114-
#% (last_thread[0], round(time_, rnd))
114+
# % (last_thread[0], round(time_, rnd))
115115
r_add('[-[#888888]-> MainThread: %s' % round(time_, rnd))
116116
time_ += dt
117117
n_with_url = href(n, str(inp), nr, 'req')

src/lcdoc/call_flows/call_flow_logging.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import os, json, sys, time
1+
import os
2+
import json
3+
import sys
4+
import time
25
from lcdoc.tools import exists, project, write_file, read_file, to_list
3-
import inspect, shutil
6+
import inspect
7+
import shutil
48
from functools import partial, wraps
59
from lcdoc.call_flows.call_flow_charting import make_call_flow_chart
610

@@ -17,7 +21,7 @@
1721
# *IF* we are in a project based on devapps, we can build call flow logs also
1822
# from pytest, not just from docs/lp. Requirements are these imports:
1923
from devapp.tools import FLG, exists, project
20-
from devapp.tools import define_flags, project, to_list
24+
from devapp.tools import define_flags, to_list
2125
from absl.flags._exceptions import UnparsedFlagAccessError
2226
except:
2327
pass
@@ -141,7 +145,7 @@ def response(frame, arg):
141145

142146
def tracer(frame, event, arg, counter=0):
143147
"""The settrace function. You can't pdb here!"""
144-
if not frame.f_code in ILS.traced:
148+
if frame.f_code not in ILS.traced:
145149
return
146150
if event == 'call':
147151
SetTrace.request(frame)
@@ -265,10 +269,6 @@ def set_flags(flags, unset=False):
265269
return [setattr(FLG, k, v) for k, v in M.items()]
266270

267271

268-
import os
269-
from functools import partial
270-
271-
272272
def pytest_plot_dest(dest):
273273
cur_test = lambda: os.environ['PYTEST_CURRENT_TEST']
274274
# if os.path.isfile(dest):
@@ -402,7 +402,7 @@ def use_case_(*args, _dest=dest, _fmt=fmt, **kwargs):
402402
min_header_level = 5
403403
section, n = n.rsplit('.', 1)
404404
have = written_sect_headers.setdefault(n_mod, {})
405-
if not section in have:
405+
if section not in have:
406406
doc += '\n\n#### ' + section
407407
have[section] = True
408408

@@ -492,7 +492,7 @@ def use_case_(*args, _dest=dest, _fmt=fmt, **kwargs):
492492

493493

494494
def strip_no_ad(s, sep='# /--'):
495-
if not sep in s:
495+
if sep not in s:
496496
return s
497497
r, add, lines = [], True, s.splitlines()
498498
while lines:
@@ -510,15 +510,14 @@ def strip_no_ad(s, sep='# /--'):
510510

511511

512512
def import_mod(test_mod_file):
513-
"""
514-
"""
515-
if not 'pytest' in sys.argv[0]:
513+
""" """
514+
if 'pytest' not in sys.argv[0]:
516515
return
517516

518-
if not '/' in test_mod_file:
517+
if '/' not in test_mod_file:
519518
test_mod_file = os.getcwd() + '/' + test_mod_file
520519
d, fn = test_mod_file.rsplit('/', 1)
521-
sys.path.insert(0, d) if not d in sys.path else 0
520+
sys.path.insert(0, d) if d not in sys.path else 0
522521
mod = import_module(fn.rsplit('.py', 1)[0])
523522

524523
fn_md = mod_doc(mod, dest='auto')

src/lcdoc/call_flows/markdown.py

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

33

44
class Mkdocs:
5-
details = '''
5+
details = """
66
77
<details>
88
<summary>%s</summary>
@@ -11,29 +11,29 @@ class Mkdocs:
1111
1212
</details>
1313
14-
'''
15-
code_ = '''
14+
"""
15+
code_ = """
1616
1717
```_code_
1818
%s
1919
```
2020
21-
'''
22-
admon_ = '''
21+
"""
22+
admon_ = """
2323
2424
!!! %s "%s"
2525
2626
%s
2727
28-
'''
28+
"""
2929
admon_closed_ = admon_.replace('!!!', '???')
3030
admon_clsabl_ = admon_.replace('!!!', '???+')
31-
tab_ = '''
31+
tab_ = """
3232
=== "%s"
3333
3434
%s
3535
36-
'''
36+
"""
3737
js = code_.replace('_code_', 'js')
3838
py = code_.replace('_code_', 'python')
3939

@@ -113,7 +113,7 @@ def extract_docstr_head(docstr):
113113
"""
114114
Finding Docstrings
115115
116-
Example: The one of this func would be 'Finding Docstrings'
116+
Example: The one of this func would be 'Finding Docstrings'
117117
"""
118118
s, rest = docstr.strip(), ''
119119
if not s:

src/lcdoc/call_flows/viz_sequence.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
from functools import partial
22

33
# fmt:off
4-
code = lambda typ, body: '''
4+
code = lambda typ, body: """
55
66
```%s
77
%s
88
```
99
10-
''' % (typ, body)
10+
""" % (typ, body)
1111

12-
call_seq_diag = '''
12+
call_seq_diag = """
1313
1414
1515
[![](.%(f)s.svg)](%(l)scall_sequence.html?src=%(f)s)
1616
1717
18-
'''
18+
"""
1919
# fmt:on
2020

2121

0 commit comments

Comments
 (0)