.../lume-gpt/gpt/gpt_phasing.py:492: SyntaxWarning: invalid escape sequence '\d'
m = re.search("\d+", line)
I took this as an opportunity to clean up some of the lint that ruff shows, along with fixing the above. Primarily:
Removing unused imports
Fixing comparisons against "True/False" (which should either be x is True or x is False or more simply if x: or if not x:)
Adding top-level package imports in __all__
Removing format string prefix f"" when there are no variables in the string
There's still more lint to clean up, but I think these are at least safe fixes for now.
Remaining lint:
```
gpt/archive.py:199:5: F821 Undefined name `gpt_input`
gpt/autoscale.py:14:1: E402 Module level import not at top of file
gpt/autoscale.py:16:1: E402 Module level import not at top of file
gpt/autoscale.py:17:1: E402 Module level import not at top of file
gpt/autoscale.py:18:1: E402 Module level import not at top of file
gpt/autoscale.py:120:9: F841 Local variable `t1` is assigned to but never used
gpt/autoscale.py:122:9: F841 Local variable `t2` is assigned to but never used
gpt/autoscale.py:185:59: F821 Undefined name `autoscale_element`
gpt/autoscale.py:190:45: F821 Undefined name `element`
gpt/autoscale.py:192:5: F821 Undefined name `lat_temp`
gpt/autoscale.py:345:9: F841 Local variable `t1` is assigned to but never used
gpt/autoscale.py:348:9: F841 Local variable `t2` is assigned to but never used
gpt/bstatic.py:25:1: E402 Module level import not at top of file
gpt/bstatic.py:27:1: E402 Module level import not at top of file
gpt/bstatic.py:28:1: E402 Module level import not at top of file
gpt/bstatic.py:159:9: F841 Local variable `e1` is assigned to but never used
gpt/bstatic.py:163:9: F841 Local variable `p_screen_a` is assigned to but never used
gpt/bstatic.py:164:9: F841 Local variable `p_screen_b` is assigned to but never used
gpt/bstatic.py:435:9: F811 Redefinition of unused `plot_field_profile` from line 203
gpt/bstatic.py:647:9: F841 Local variable `D` is assigned to but never used
gpt/bstatic.py:861:9: F841 Local variable `D` is assigned to but never used
gpt/bstatic.py:1034:28: E701 Multiple statements on one line (colon)
gpt/easygdf.py:205:13: F841 Local variable `directory` is assigned to but never used
gpt/easygdf.py:207:13: F841 Local variable `single` is assigned to but never used
gpt/easygdf.py:428:13: F841 Local variable `directory` is assigned to but never used
gpt/easygdf.py:430:13: F841 Local variable `single` is assigned to but never used
gpt/easygdf.py:577:5: F841 Local variable `block_value` is assigned to but never used
gpt/easygdf.py:598:9: F841 Local variable `directory` is assigned to but never used
gpt/easygdf.py:599:9: F841 Local variable `end` is assigned to but never used
gpt/easygdf.py:600:9: F841 Local variable `single` is assigned to but never used
gpt/easygdf.py:601:9: F841 Local variable `array` is assigned to but never used
gpt/easygdf.py:633:5: F841 Local variable `q` is assigned to but never used
gpt/easygdf.py:693:5: F841 Local variable `block_value` is assigned to but never used
gpt/easygdf.py:714:9: F841 Local variable `directory` is assigned to but never used
gpt/easygdf.py:715:9: F841 Local variable `end` is assigned to but never used
gpt/easygdf.py:716:9: F841 Local variable `single` is assigned to but never used
gpt/easygdf.py:717:9: F841 Local variable `array` is assigned to but never used
gpt/element.py:491:9: F841 Local variable `h2` is assigned to but never used
gpt/gpt.py:30:1: E402 Module level import not at top of file
gpt/gpt.py:200:9: F841 Local variable `results` is assigned to but never used
gpt/gpt.py:230:9: F841 Local variable `runscript` is assigned to but never used
gpt/gpt.py:386:13: F841 Local variable `outfile` is assigned to but never used
gpt/gpt_distgen.py:434:5: F841 Local variable `f2` is assigned to but never used
gpt/gpt_phasing.py:35:5: F841 Local variable `verbose` is assigned to but never used
gpt/gpt_phasing.py:36:5: F841 Local variable `debug_flag` is assigned to but never used
gpt/gpt_phasing.py:40:5: F841 Local variable `path_to_gpt_bin` is assigned to but never used
gpt/gpt_phasing.py:64:5: F841 Local variable `extension` is assigned to but never used
gpt/gpt_phasing.py:222:13: F841 Local variable `best_gamma` is assigned to but never used
gpt/gpt_phasing.py:332:9: F841 Local variable `result` is assigned to but never used
gpt/gpt_phasing.py:351:9: F841 Local variable `last_screen` is assigned to but never used
gpt/gpt_phasing.py:363:9: F841 Local variable `output_text_filename` is assigned to but never used
gpt/gpt_tao.py:17:1: E402 Module level import not at top of file
gpt/gpt_tao.py:96:9: F841 Local variable `zmirror` is assigned to but never used
gpt/gpt_tao.py:98:5: F841 Local variable `L_fm` is assigned to but never used
gpt/gpt_tao.py:135:9: F841 Local variable `efactor` is assigned to but never used
gpt/gpt_tao.py:150:9: F841 Local variable `theta0_deg` is assigned to but never used
gpt/gpt_tao.py:213:5: E722 Do not use bare `except`
gpt/gpt_tao.py:225:5: F841 Local variable `unique_name` is assigned to but never used
gpt/gpt_tao.py:232:5: F841 Local variable `all_eles_wild_card_str` is assigned to but never used
gpt/lattice.py:383:9: F841 Local variable `fmap_name` is assigned to but never used
gpt/lattice.py:468:9: F841 Local variable `lines` is assigned to but never used
gpt/maps.py:25:1: E402 Module level import not at top of file
gpt/maps.py:37:19: F821 Undefined name `mc2`
gpt/maps.py:41:12: F821 Undefined name `mc2`
gpt/maps.py:449:5: F841 Local variable `t` is assigned to but never used
gpt/maps.py:452:9: F821 Undefined name `E2b`
gpt/maps.py:1242:9: F821 Undefined name `GPT`
gpt/parsers.py:202:9: F841 Local variable `q` is assigned to but never used
gpt/parsers.py:203:9: F841 Local variable `nmacro` is assigned to but never used
gpt/parsers.py:345:5: F841 Local variable `t2` is assigned to but never used
gpt/particles.py:64:5: F841 Local variable `factor` is assigned to but never used
gpt/plot.py:39:5: E741 Ambiguous variable name: `I`
gpt/tools.py:70:5: E722 Do not use bare `except`
gpt/tools.py:116:9: F841 Local variable `rc` is assigned to but never used
gpt/tools.py:119:9: F841 Local variable `exectption` is assigned to but never used
gpt/tools.py:220:5: E722 Do not use bare `except`
Found 76 errors.
No fixes available (52 hidden fixes can be enabled with the `--unsafe-fixes` option).
```
gpt
was showing the following:ruff
shows, along with fixing the above. Primarily:x is True
orx is False
or more simplyif x:
orif not x:
)__all__
f""
when there are no variables in the stringThere's still more lint to clean up, but I think these are at least safe fixes for now.