Skip to content

Instantly share code, notes, and snippets.

@serjflint
Created July 24, 2025 13:38
Show Gist options
  • Save serjflint/ea474c222a3383af0cfe45fd390ac48b to your computer and use it in GitHub Desktop.
Save serjflint/ea474c222a3383af0cfe45fd390ac48b to your computer and use it in GitHub Desktop.
Merge your rules with proposed
import tomllib
import pathlib
FILE = pathlib.Path('~/pyproject.toml').expanduser()
with FILE.open(mode='rb') as f:
conf = tomllib.load(f)
enabled = conf['tool']['ruff']['lint']['select']
proposed = """
ASYNC115
B009
B010
B013
B014
B028
B905
C400
C401
C402
C403
C404
C405
C406
C409
C410
C411
C413
C414
C418
COM819
DTZ001
DTZ002
DTZ003
DTZ004
DTZ005
DTZ006
DTZ007
DTZ011
DTZ012
DTZ901
E101
E111
E112
E113
E114
E115
E116
E117
E201
E202
E203
E204
E211
E221
E222
E223
E224
E225
E226
E227
E228
E231
E241
E242
E251
E252
E261
E262
E265
E266
E271
E272
E273
E274
E275
E301
E302
E303
E304
E305
E306
E401
E402
E502
E701
E702
E703
E711
E712
E713
E714
E721
E722
E731
E741
E742
E743
E902
EXE004
F401
F402
F403
F404
F405
F406
F407
F501
F502
F503
F504
F505
F506
F507
F508
F509
F521
F522
F523
F524
F525
F541
F601
F602
F621
F622
F631
F632
F633
F634
F701
F702
F704
F706
F707
F722
F811
F821
F822
F823
F841
F842
F901
FA102
FAST001
FLY002
FURB122
FURB129
FURB132
FURB157
FURB161
FURB162
FURB166
FURB167
FURB169
FURB187
FURB188
G010
I002
ISC003
PERF101
PERF102
PIE790
PIE794
PIE808
PIE810
PLC0208
PLC1802
PLE0100
PLE0101
PLE0115
PLE0116
PLE0117
PLE0118
PLE0237
PLE0241
PLE0302
PLE0303
PLE0304
PLE0305
PLE0307
PLE0308
PLE0309
PLE0604
PLE0605
PLE0643
PLE0704
PLE1132
PLE1141
PLE1142
PLE1205
PLE1206
PLE1300
PLE1307
PLE1310
PLE1507
PLE1519
PLE1520
PLE1700
PLE2502
PLE2510
PLE2512
PLE2513
PLE2514
PLE2515
PLE4703
PLR0202
PLR0203
PLR1711
PLR1714
PLR1716
PLR1733
PLR1736
PLR2044
PLR6104
PLW0108
PLW0120
PLW0133
PLW0245
PLW1507
PLW1510
PLW1514
PLW3301
PT003
PT022
PT023
PT024
PT025
PT026
PTH201
PYI009
PYI010
PYI011
PYI012
PYI014
PYI015
PYI020
PYI021
PYI026
PYI029
PYI032
PYI053
PYI054
PYI062
Q001
Q003
Q004
RET501
RET502
RUF015
RUF017
RUF019
RUF021
RUF028
RUF030
RUF032
RUF046
RUF051
RUF057
SIM109
SIM201
SIM202
SIM208
SIM211
SIM212
SIM220
SIM221
SIM222
SIM223
SIM910
SIM911
TC005
TD006
TRY201
UP001
UP004
UP005
UP009
UP010
UP011
UP012
UP015
UP018
UP021
UP023
UP024
UP025
UP026
UP029
UP033
UP034
UP037
UP039
UP040
UP041
UP043
UP044
UP047
W291
W292
W293
W391
W605
""".strip().splitlines()
res = set(proposed) - set(enabled)
import json
import subprocess
RUFF_CONFIG_CMD = 'uvx ruff rule --all --output-format=json'
def get_ruff_rules():
result = subprocess.run(RUFF_CONFIG_CMD, shell=True, capture_output=True, text=True)
return json.loads(result.stdout)
def main():
mapping = {r['code']: r['name'] for r in get_ruff_rules()}
for code in sorted(res):
name = mapping[code]
print(f' "{code}", # {name}')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment