Skip to content

Commit 480ca61

Browse files
committed
typing
1 parent a2034ae commit 480ca61

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

prettyconfig/conf/settings.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
gitignore_directories = set([])
2121
with open(".gitignore", "rb") as f:
2222
for line in f.readlines():
23-
line = line.decode("utf-8")
24-
if "*" in line:
23+
line_string = line.decode("utf-8")
24+
if "*" in line_string:
2525
continue
26-
if line.startswith("#"):
26+
if line_string.startswith("#"):
2727
continue
28-
if "#" in line:
29-
line = line.split("#")[0]
30-
line = line.strip().strip("/")
31-
if len(line) == 0:
28+
if "#" in line_string:
29+
line_string = line_string.split("#")[0]
30+
line_string = line_string.strip().strip("/")
31+
if len(line_string) == 0:
3232
continue
33-
gitignore_directories.add(line)
33+
gitignore_directories.add(line_string)
3434
if len(gitignore_directories) > 0:
3535
default_data["exclude_paths"] = set(default_data.get("exclude_paths", [])) | gitignore_directories
3636

prettyconfig/formatters/yaml.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ def dump(self, data: Any, stream=None, **kw) -> None | str:
1616
YAML.dump(self, data, stream, **kw)
1717
if return_string:
1818
return stream.getvalue()
19+
return None
1920

2021

2122
#
2223
# Overload the comment writer to remove superfluous newlines.
2324
#
2425

2526
# Save the original comment writer so our extended version can use it.
26-
ruamel.yaml.emitter.Emitter.write_comment_original = ruamel.yaml.emitter.Emitter.write_comment
27+
ruamel.yaml.emitter.Emitter.write_comment_original = ruamel.yaml.emitter.Emitter.write_comment # type: ignore
2728

2829
# Create the new comment writer.
29-
def strip_empty_lines_write_comment(self, comment, pre=False):
30+
def strip_empty_lines_write_comment(self, comment: Any, pre: bool = False) -> None:
3031
# Check if comment is nothing but newlines.
3132
# Then replace with a single new line.
3233
string_check = comment.value.replace("\n", "")
@@ -37,13 +38,13 @@ def strip_empty_lines_write_comment(self, comment, pre=False):
3738

3839

3940
# Set ruamel.yaml to use the new writer.
40-
ruamel.yaml.emitter.Emitter.write_comment = strip_empty_lines_write_comment
41+
ruamel.yaml.emitter.Emitter.write_comment = strip_empty_lines_write_comment # type: ignore
4142

4243

4344
yaml = YAMLWithStrings()
44-
yaml.preserve_quotes = True
45+
yaml.preserve_quotes = True # type: ignore
4546
yaml.default_flow_style = False
46-
yaml.width = 120
47+
yaml.width = 120 # type: ignore
4748
yaml.indent(mapping=2, sequence=4, offset=2)
4849

4950

@@ -52,4 +53,4 @@ def yaml_formatter(input: str) -> str:
5253
# comments and other useful data. The dump function uses that to add
5354
# comments back in.
5455
data = yaml.load(input)
55-
return yaml.dump(data)
56+
return yaml.dump(data) # type: ignore

0 commit comments

Comments
 (0)