diff options
author | Florian Bruhin <me@the-compiler.org> | 2022-05-17 13:39:52 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2022-06-22 17:41:12 +0200 |
commit | 64b7cebb0817ce02c4f1e041be4b76b830556896 (patch) | |
tree | 0347e1d6926f3f77f098205f33c8eda9fc2e3caa | |
parent | 52ab507ca5e8c4fc140eff55fd3af59b97873136 (diff) | |
download | qutebrowser-64b7cebb0817ce02c4f1e041be4b76b830556896.tar.gz qutebrowser-64b7cebb0817ce02c4f1e041be4b76b830556896.zip |
lint: Fix rewrite scripts
-rw-r--r-- | scripts/dev/rewrite_enums.py | 8 | ||||
-rw-r--r-- | scripts/dev/rewrite_find_enums.py | 3 | ||||
-rw-r--r-- | scripts/dev/rewrite_find_flags.py | 3 |
3 files changed, 11 insertions, 3 deletions
diff --git a/scripts/dev/rewrite_enums.py b/scripts/dev/rewrite_enums.py index abf772a53..6de906ded 100644 --- a/scripts/dev/rewrite_enums.py +++ b/scripts/dev/rewrite_enums.py @@ -1,3 +1,5 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + """Rewrite PyQt enums based on rewrite_find_enums.py output.""" @@ -8,7 +10,7 @@ import re script_path = pathlib.Path(__file__).parent replacements = [] -with (script_path / 'enums.txt').open() as f: +with (script_path / 'enums.txt').open(encoding="utf-8") as f: for line in f: orig, replacement = line.split() orig_re = re.compile(re.escape(orig) + r'(?=\W)') @@ -19,8 +21,8 @@ for filename in sys.argv[1:]: path = pathlib.Path(filename) if path.suffix != '.py': continue - content = path.read_text() + content = path.read_text(encoding="utf-8") print(filename) for orig_re, replacement in replacements: content = orig_re.sub(replacement, content) - path.write_text(content) + path.write_text(content, encoding="utf-8") diff --git a/scripts/dev/rewrite_find_enums.py b/scripts/dev/rewrite_find_enums.py index a15ae6046..8425d94e3 100644 --- a/scripts/dev/rewrite_find_enums.py +++ b/scripts/dev/rewrite_find_enums.py @@ -1,3 +1,5 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + """Find all PyQt enum instances.""" @@ -8,6 +10,7 @@ import PyQt5 def find_enums(tree): + """Find all PyQt enums in an AST tree.""" for node in ast.walk(tree): if not isinstance(node, ast.Assign): continue diff --git a/scripts/dev/rewrite_find_flags.py b/scripts/dev/rewrite_find_flags.py index 704f294c8..8f587e198 100644 --- a/scripts/dev/rewrite_find_flags.py +++ b/scripts/dev/rewrite_find_flags.py @@ -1,3 +1,5 @@ +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + """Find all PyQt flag instances.""" import pathlib @@ -7,6 +9,7 @@ import PyQt5 def find_flags(tree): + """Find all PyQt flags in an AST tree.""" for node in ast.walk(tree): if not isinstance(node, ast.FunctionDef): continue |