Skip to content

Commit 265eb14

Browse files
committed
fix!: Fix shadowing of python builtins
docs/_ext/aafig.py:59:5: A001 Variable `id` is shadowing a Python builtin docs/_ext/aafig.py:121:9: A001 Variable `format` is shadowing a Python builtin docs/_ext/aafig.py:137:27: A001 Variable `id` is shadowing a Python builtin docs/conf.py:59:1: A001 Variable `copyright` is shadowing a Python builtin src/tmuxp/_internal/config_reader.py:30:15: A002 Argument `format` is shadowing a Python builtin src/tmuxp/_internal/config_reader.py:54:19: A002 Argument `format` is shadowing a Python builtin src/tmuxp/_internal/config_reader.py:110:13: A001 Variable `format` is shadowing a Python builtin src/tmuxp/_internal/config_reader.py:112:13: A001 Variable `format` is shadowing a Python builtin src/tmuxp/_internal/config_reader.py:164:9: A002 Argument `format` is shadowing a Python builtin src/tmuxp/_internal/config_reader.py:193:20: A002 Argument `format` is shadowing a Python builtin Found 10 errors.
1 parent 566ed09 commit 265eb14

File tree

13 files changed

+57
-57
lines changed

13 files changed

+57
-57
lines changed

docs/_ext/aafig.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def get_basename(
5656
if "format" in options:
5757
del options["format"]
5858
hashkey = text + str(options)
59-
id = sha(hashkey.encode("utf-8")).hexdigest()
60-
return f"{prefix}-{id}"
59+
_id = sha(hashkey.encode("utf-8")).hexdigest()
60+
return f"{prefix}-{_id}"
6161

6262

6363
class AafigError(SphinxError):
@@ -118,23 +118,23 @@ def render_aafig_images(app: "Sphinx", doctree: nodes.Node) -> None:
118118
continue
119119
options = img.aafig["options"]
120120
text = img.aafig["text"]
121-
format = app.builder.format
121+
_format = app.builder.format
122122
merge_dict(options, app.builder.config.aafig_default_options)
123-
if format in format_map:
124-
options["format"] = format_map[format]
123+
if _format in format_map:
124+
options["format"] = format_map[_format]
125125
else:
126126
logger.warn(
127127
'unsupported builder format "%s", please '
128128
"add a custom entry in aafig_format config "
129-
"option for this builder" % format,
129+
"option for this builder" % _format,
130130
)
131131
img.replace_self(nodes.literal_block(text, text))
132132
continue
133133
if options["format"] is None:
134134
img.replace_self(nodes.literal_block(text, text))
135135
continue
136136
try:
137-
fname, outfn, id, extra = render_aafigure(app, text, options)
137+
fname, outfn, _id, extra = render_aafigure(app, text, options)
138138
except AafigError as exc:
139139
logger.warn("aafigure error: " + str(exc))
140140
img.replace_self(nodes.literal_block(text, text))

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
master_doc = "index"
5757

5858
project = about["__title__"]
59-
copyright = about["__copyright__"]
59+
project_copyright = about["__copyright__"]
6060

6161
version = "%s" % (".".join(about["__version__"].split("."))[:2])
6262
release = "%s" % (about["__version__"])

src/tmuxp/_internal/config_reader.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, content: "RawConfigData") -> None:
2727
self.content = content
2828

2929
@staticmethod
30-
def _load(format: "FormatLiteral", content: str) -> t.Dict[str, t.Any]:
30+
def _load(fmt: "FormatLiteral", content: str) -> t.Dict[str, t.Any]:
3131
"""Load raw config data and directly return it.
3232
3333
>>> ConfigReader._load("json", '{ "session_name": "my session" }')
@@ -36,22 +36,22 @@ def _load(format: "FormatLiteral", content: str) -> t.Dict[str, t.Any]:
3636
>>> ConfigReader._load("yaml", 'session_name: my session')
3737
{'session_name': 'my session'}
3838
"""
39-
if format == "yaml":
39+
if fmt == "yaml":
4040
return t.cast(
4141
t.Dict[str, t.Any],
4242
yaml.load(
4343
content,
4444
Loader=yaml.SafeLoader,
4545
),
4646
)
47-
elif format == "json":
47+
elif fmt == "json":
4848
return t.cast(t.Dict[str, t.Any], json.loads(content))
4949
else:
50-
msg = f"{format} not supported in configuration"
50+
msg = f"{fmt} not supported in configuration"
5151
raise NotImplementedError(msg)
5252

5353
@classmethod
54-
def load(cls, format: "FormatLiteral", content: str) -> "ConfigReader":
54+
def load(cls, fmt: "FormatLiteral", content: str) -> "ConfigReader":
5555
"""Load raw config data into a ConfigReader instance (to dump later).
5656
5757
>>> cfg = ConfigReader.load("json", '{ "session_name": "my session" }')
@@ -68,7 +68,7 @@ def load(cls, format: "FormatLiteral", content: str) -> "ConfigReader":
6868
"""
6969
return cls(
7070
content=cls._load(
71-
format=format,
71+
fmt=fmt,
7272
content=content,
7373
),
7474
)
@@ -107,15 +107,15 @@ def _from_file(cls, path: pathlib.Path) -> t.Dict[str, t.Any]:
107107
content = path.open().read()
108108

109109
if path.suffix in [".yaml", ".yml"]:
110-
format: "FormatLiteral" = "yaml"
110+
fmt: "FormatLiteral" = "yaml"
111111
elif path.suffix == ".json":
112-
format = "json"
112+
fmt = "json"
113113
else:
114114
msg = f"{path.suffix} not supported in {path}"
115115
raise NotImplementedError(msg)
116116

117117
return cls._load(
118-
format=format,
118+
fmt=fmt,
119119
content=content,
120120
)
121121

@@ -161,7 +161,7 @@ def from_file(cls, path: pathlib.Path) -> "ConfigReader":
161161

162162
@staticmethod
163163
def _dump(
164-
format: "FormatLiteral",
164+
fmt: "FormatLiteral",
165165
content: "RawConfigData",
166166
indent: int = 2,
167167
**kwargs: t.Any,
@@ -174,23 +174,23 @@ def _dump(
174174
>>> ConfigReader._dump("json", { "session_name": "my session" })
175175
'{\n "session_name": "my session"\n}'
176176
"""
177-
if format == "yaml":
177+
if fmt == "yaml":
178178
return yaml.dump(
179179
content,
180180
indent=2,
181181
default_flow_style=False,
182182
Dumper=yaml.SafeDumper,
183183
)
184-
elif format == "json":
184+
elif fmt == "json":
185185
return json.dumps(
186186
content,
187187
indent=2,
188188
)
189189
else:
190-
msg = f"{format} not supported in config"
190+
msg = f"{fmt} not supported in config"
191191
raise NotImplementedError(msg)
192192

193-
def dump(self, format: "FormatLiteral", indent: int = 2, **kwargs: t.Any) -> str:
193+
def dump(self, fmt: "FormatLiteral", indent: int = 2, **kwargs: t.Any) -> str:
194194
r"""Dump via ConfigReader instance.
195195
196196
>>> cfg = ConfigReader({ "session_name": "my session" })
@@ -200,7 +200,7 @@ def dump(self, format: "FormatLiteral", indent: int = 2, **kwargs: t.Any) -> str
200200
'{\n "session_name": "my session"\n}'
201201
"""
202202
return self._dump(
203-
format=format,
203+
fmt=fmt,
204204
content=self.content,
205205
indent=indent,
206206
**kwargs,

src/tmuxp/cli/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def command_convert(
7878
newfile = workspace_file.parent / (str(workspace_file.stem) + f".{to_filetype}")
7979

8080
new_workspace = configparser.dump(
81-
format=to_filetype,
81+
fmt=to_filetype,
8282
indent=2,
8383
**{"default_flow_style": False} if to_filetype == "yaml" else {},
8484
)

src/tmuxp/cli/freeze.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ def extract_workspace_format(
193193

194194
if workspace_format == "yaml":
195195
workspace = configparser.dump(
196-
format="yaml",
196+
fmt="yaml",
197197
indent=2,
198198
default_flow_style=False,
199199
safe=True,
200200
)
201201
elif workspace_format == "json":
202-
workspace = configparser.dump(format="json", indent=2)
202+
workspace = configparser.dump(fmt="json", indent=2)
203203

204204
if args.answer_yes or prompt_yes_no("Save to %s?" % dest):
205205
destdir = os.path.dirname(dest)

tests/cli/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_reattach_plugins(
135135
"""Test reattach plugin hook."""
136136
config_plugins = test_utils.read_workspace_file("workspace/builder/plugin_r.yaml")
137137

138-
session_config = ConfigReader._load(format="yaml", content=config_plugins)
138+
session_config = ConfigReader._load(fmt="yaml", content=config_plugins)
139139
session_config = loader.expand(session_config)
140140

141141
# open it detached

tests/cli/test_freeze.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_freeze(
6060
assert yaml_config_path.exists()
6161

6262
yaml_config = yaml_config_path.open().read()
63-
frozen_config = ConfigReader._load(format="yaml", content=yaml_config)
63+
frozen_config = ConfigReader._load(fmt="yaml", content=yaml_config)
6464

6565
assert frozen_config["session_name"] == "myfrozensession"
6666

tests/cli/test_load.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ def test_load_plugins(
462462

463463
plugins_config = test_utils.read_workspace_file("workspace/builder/plugin_bwb.yaml")
464464

465-
session_config = ConfigReader._load(format="yaml", content=plugins_config)
465+
session_config = ConfigReader._load(fmt="yaml", content=plugins_config)
466466
session_config = loader.expand(session_config)
467467

468468
plugins = load_plugins(session_config)
@@ -582,7 +582,7 @@ def test_load_attached(
582582
attach_session_mock.return_value.stderr = None
583583

584584
yaml_config = test_utils.read_workspace_file("workspace/builder/two_pane.yaml")
585-
session_config = ConfigReader._load(format="yaml", content=yaml_config)
585+
session_config = ConfigReader._load(fmt="yaml", content=yaml_config)
586586

587587
builder = WorkspaceBuilder(session_config=session_config, server=server)
588588

@@ -604,7 +604,7 @@ def test_load_attached_detached(
604604
attach_session_mock.return_value.stderr = None
605605

606606
yaml_config = test_utils.read_workspace_file("workspace/builder/two_pane.yaml")
607-
session_config = ConfigReader._load(format="yaml", content=yaml_config)
607+
session_config = ConfigReader._load(fmt="yaml", content=yaml_config)
608608

609609
builder = WorkspaceBuilder(session_config=session_config, server=server)
610610

@@ -626,7 +626,7 @@ def test_load_attached_within_tmux(
626626
switch_client_mock.return_value.stderr = None
627627

628628
yaml_config = test_utils.read_workspace_file("workspace/builder/two_pane.yaml")
629-
session_config = ConfigReader._load(format="yaml", content=yaml_config)
629+
session_config = ConfigReader._load(fmt="yaml", content=yaml_config)
630630

631631
builder = WorkspaceBuilder(session_config=session_config, server=server)
632632

@@ -648,7 +648,7 @@ def test_load_attached_within_tmux_detached(
648648
switch_client_mock.return_value.stderr = None
649649

650650
yaml_config = test_utils.read_workspace_file("workspace/builder/two_pane.yaml")
651-
session_config = ConfigReader._load(format="yaml", content=yaml_config)
651+
session_config = ConfigReader._load(fmt="yaml", content=yaml_config)
652652

653653
builder = WorkspaceBuilder(session_config=session_config, server=server)
654654

@@ -663,7 +663,7 @@ def test_load_append_windows_to_current_session(
663663
) -> None:
664664
"""Test tmuxp load when windows are appended to the current session."""
665665
yaml_config = test_utils.read_workspace_file("workspace/builder/two_pane.yaml")
666-
session_config = ConfigReader._load(format="yaml", content=yaml_config)
666+
session_config = ConfigReader._load(fmt="yaml", content=yaml_config)
667667

668668
builder = WorkspaceBuilder(session_config=session_config, server=server)
669669
builder.build()

tests/workspace/test_builder.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ def test_start_directory(session: Session, tmp_path: pathlib.Path) -> None:
571571
)
572572
test_config = yaml_workspace.format(TEST_DIR=test_dir)
573573

574-
workspace = ConfigReader._load(format="yaml", content=test_config)
574+
workspace = ConfigReader._load(fmt="yaml", content=test_config)
575575
workspace = loader.expand(workspace)
576576
workspace = loader.trickle(workspace)
577577

@@ -620,7 +620,7 @@ def test_start_directory_relative(session: Session, tmp_path: pathlib.Path) -> N
620620
config_dir.mkdir()
621621

622622
test_config = yaml_workspace.format(TEST_DIR=test_dir)
623-
workspace = ConfigReader._load(format="yaml", content=test_config)
623+
workspace = ConfigReader._load(fmt="yaml", content=test_config)
624624
# the second argument of os.getcwd() mimics the behavior
625625
# the CLI loader will do, but it passes in the workspace file's location.
626626
workspace = loader.expand(workspace, config_dir)
@@ -692,7 +692,7 @@ def test_pane_order(session: Session) -> None:
692692
str(pathlib.Path().home().resolve()),
693693
]
694694

695-
workspace = ConfigReader._load(format="yaml", content=yaml_workspace)
695+
workspace = ConfigReader._load(fmt="yaml", content=yaml_workspace)
696696
workspace = loader.expand(workspace)
697697
workspace = loader.trickle(workspace)
698698

@@ -761,7 +761,7 @@ def test_before_script_throw_error_if_retcode_error(
761761
script_failed=FIXTURE_PATH / "script_failed.sh",
762762
)
763763

764-
workspace = ConfigReader._load(format="yaml", content=yaml_workspace)
764+
workspace = ConfigReader._load(fmt="yaml", content=yaml_workspace)
765765
workspace = loader.expand(workspace)
766766
workspace = loader.trickle(workspace)
767767

@@ -788,7 +788,7 @@ def test_before_script_throw_error_if_file_not_exists(
788788
yaml_workspace = config_script_not_exists.format(
789789
script_not_exists=FIXTURE_PATH / "script_not_exists.sh",
790790
)
791-
workspace = ConfigReader._load(format="yaml", content=yaml_workspace)
791+
workspace = ConfigReader._load(fmt="yaml", content=yaml_workspace)
792792
workspace = loader.expand(workspace)
793793
workspace = loader.trickle(workspace)
794794

@@ -818,7 +818,7 @@ def test_before_script_true_if_test_passes(
818818
assert script_complete_sh.exists()
819819

820820
yaml_workspace = config_script_completes.format(script_complete=script_complete_sh)
821-
workspace = ConfigReader._load(format="yaml", content=yaml_workspace)
821+
workspace = ConfigReader._load(fmt="yaml", content=yaml_workspace)
822822
workspace = loader.expand(workspace)
823823
workspace = loader.trickle(workspace)
824824

@@ -840,7 +840,7 @@ def test_before_script_true_if_test_passes_with_args(
840840

841841
yaml_workspace = config_script_completes.format(script_complete=script_complete_sh)
842842

843-
workspace = ConfigReader._load(format="yaml", content=yaml_workspace)
843+
workspace = ConfigReader._load(fmt="yaml", content=yaml_workspace)
844844
workspace = loader.expand(workspace)
845845
workspace = loader.trickle(workspace)
846846

0 commit comments

Comments
 (0)