Skip to content

Commit 7279b81

Browse files
style: fix ruff and ty linting errors
1 parent 61b3ed6 commit 7279b81

3 files changed

Lines changed: 49 additions & 47 deletions

File tree

src/edit_python_pe/main.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def value(self):
9696
@value.setter
9797
def value(self, v: str):
9898
self._value = v
99-
self.query_one(selector="#input").value = v
99+
self.query_one(selector="#input").value = v # type: ignore
100100

101101

102102
class SocialEntry(Horizontal):
@@ -160,7 +160,7 @@ def compose(self) -> ComposeResult:
160160

161161

162162
class MemberApp(App):
163-
"""Single app that toggles between a file list and a form while connected to a GitHub fork+push flow."""
163+
"""Single app that toggles between a file list and a form while connected to a GitHub fork+push flow.""" # noqa: E501
164164

165165
def __init__(
166166
self,
@@ -176,7 +176,7 @@ def __init__(
176176
self.repo_path = repo_path
177177

178178
def compose(self) -> ComposeResult:
179-
# Two main containers: self.list_container for the file list, self.form_container for the form.
179+
# Two main containers: self.list_container for the file list, self.form_container for the form. # noqa: E501
180180
self.list_container = Vertical()
181181
yield self.list_container
182182

@@ -314,9 +314,9 @@ def clear_form(self) -> None:
314314
self.alias_container.remove_children()
315315

316316
def on_list_view_selected(self, event: ListView.Selected) -> None:
317-
"""User clicked on a file in the list. Parse it into the form fields."""
317+
"""User clicked on a file in the list. Parse it into the form fields.""" # noqa: E501
318318
item_text_widget = event.item.children[0]
319-
filename = item_text_widget.content
319+
filename = item_text_widget.content # type: ignore
320320
self.current_file = filename
321321

322322
self.clear_form()
@@ -351,9 +351,10 @@ def on_button_pressed(self, event: Button.Pressed) -> None:
351351
self.remove_alias_entry(index)
352352

353353
def add_social_entry(
354-
self, value: str | NoSelection = Select.BLANK
354+
self,
355+
value: str | NoSelection = Select.BLANK, # type: ignore
355356
) -> None:
356-
new_entry = SocialEntry(self.social_index, value)
357+
new_entry = SocialEntry(self.social_index, value) # type: ignore
357358
self.social_index += 1
358359
self.social_entries.append(new_entry)
359360
self.social_container.mount(new_entry)
@@ -407,7 +408,7 @@ def save_member(self) -> None:
407408
plat = se.select.value
408409
urlval = se.url_input.value.strip()
409410
if plat and urlval:
410-
socials.append((plat, urlval))
411+
socials.append((str(plat), urlval))
411412

412413
# Build the markdown doc as per the provided guide
413414
md_content = build_md_content(

src/edit_python_pe/strings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@
8484
"yaml_excerpt": "excerpt: 1",
8585
"yaml_end": "---",
8686
"header_name": "# {name}",
87-
"gravatar_block": '```{{gravatar}} {email}\n---\nwidth: 200\nclass: "member-gravatar"\n---\n```',
87+
"gravatar_block": '```{{gravatar}} {email}\n---\nwidth: 200\nclass: "member-gravatar"\n---\n```', # noqa: E501
8888
"social_block_start": "```{{raw}} html",
8989
"social_ul_start": '<ul class="social-media profile">',
90-
"social_li": ' <li>\n <a class="external reference" href="{url}">\n <iconify-icon icon="simple-icons:{platform}" style="font-size:2em"></iconify-icon>\n </a>\n </li>',
90+
"social_li": ' <li>\n <a class="external reference" href="{url}">\n <iconify-icon icon="simple-icons:{platform}" style="font-size:2em"></iconify-icon>\n </a>\n </li>', # noqa: E501
9191
"social_ul_end": "</ul>",
9292
"social_block_end": "```",
9393
"aliases": ":Aliases: {aliases}",
@@ -97,5 +97,5 @@
9797
"section_who": "### ¿Quién eres y a qué te dedicas?",
9898
"section_python": "### ¿Cómo programas en Python?",
9999
"section_contrib": "### ¿Tienes algún aporte a la comunidad de Python?",
100-
"section_avail": "### ¿Estás disponible para hacer mentoring, consultorías, charlas?",
100+
"section_avail": "### ¿Estás disponible para hacer mentoring, consultorías, charlas?", # noqa: E501
101101
}

tests/test_member_app.py

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
22
import sys
33
import unittest
4-
from unittest.mock import MagicMock, patch
4+
import unittest.mock
5+
from unittest.mock import ANY, MagicMock, patch
56

67
sys.path.insert(
78
0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../src"))
@@ -42,14 +43,14 @@ class StubTextArea:
4243
def __init__(self):
4344
self.text = ""
4445

45-
self.app.name_input = StubInput()
46-
self.app.email_input = StubInput()
47-
self.app.city_input = StubInput()
48-
self.app.homepage_input = StubInput()
49-
self.app.who_area = StubTextArea()
50-
self.app.python_area = StubTextArea()
51-
self.app.contributions_area = StubTextArea()
52-
self.app.availability_area = StubTextArea()
46+
self.app.name_input = StubInput() # type: ignore
47+
self.app.email_input = StubInput() # type: ignore
48+
self.app.city_input = StubInput() # type: ignore
49+
self.app.homepage_input = StubInput() # type: ignore
50+
self.app.who_area = StubTextArea() # type: ignore
51+
self.app.python_area = StubTextArea() # type: ignore
52+
self.app.contributions_area = StubTextArea() # type: ignore
53+
self.app.availability_area = StubTextArea() # type: ignore
5354

5455
# Patch remove method for entries to avoid Textual lifecycle errors
5556
# Use stub classes for entries with .remove() method
@@ -76,18 +77,18 @@ def remove(self):
7677
def test_add_social_entry(self):
7778
# Patch add_social_entry to use stub
7879
self.app.social_entries = []
79-
self.app.social_container.mount = MagicMock()
80+
self.app.social_container.mount = MagicMock() # type: ignore
8081
# Patch mount to accept any object
8182
self.app.social_container.mount = lambda x: None # type: ignore
8283

8384
def stub_add_social_entry(value):
8485
entry = self.StubSocialEntry()
8586
entry.index = self.app.social_index
8687
self.app.social_index += 1
87-
self.app.social_entries.append(entry)
88-
self.app.social_container.mount(entry)
88+
self.app.social_entries.append(entry) # type: ignore
89+
self.app.social_container.mount(entry) # type: ignore
8990

90-
self.app.add_social_entry = stub_add_social_entry
91+
self.app.add_social_entry = stub_add_social_entry # type: ignore
9192
initial_count = len(self.app.social_entries)
9293
self.app.add_social_entry("")
9394
self.assertEqual(len(self.app.social_entries), initial_count + 1)
@@ -104,8 +105,8 @@ def test_add_list_button_clears_form(self):
104105
self.app.contributions_area.text = "Filled Contributions"
105106
self.app.availability_area.text = "Filled Available"
106107
# Add social and alias entries
107-
self.app.social_entries = [self.StubSocialEntry()]
108-
self.app.alias_entries = [self.StubAliasEntry()]
108+
self.app.social_entries = [self.StubSocialEntry()] # type: ignore
109+
self.app.alias_entries = [self.StubAliasEntry()] # type: ignore
109110

110111
# Simulate pressing the 'Añadir' button on the list screen
111112
class DummyButton:
@@ -114,7 +115,7 @@ class DummyButton:
114115
class DummyEvent:
115116
button = DummyButton()
116117

117-
self.app.on_button_pressed(DummyEvent())
118+
self.app.on_button_pressed(DummyEvent()) # type: ignore
118119
# After pressing, form should be cleared and current_file should be None
119120
self.assertEqual(self.app.name_input.value, "")
120121
self.assertEqual(self.app.email_input.value, "")
@@ -137,18 +138,18 @@ class DummyEvent:
137138
def test_add_alias_entry(self):
138139
# Patch add_alias_entry to use stub
139140
self.app.alias_entries = []
140-
self.app.alias_container.mount = MagicMock()
141+
self.app.alias_container.mount = MagicMock() # type: ignore
141142
# Patch mount to accept any object
142143
self.app.alias_container.mount = lambda x: None # type: ignore
143144

144145
def stub_add_alias_entry():
145146
entry = self.StubAliasEntry()
146147
entry.index = self.app.alias_index
147148
self.app.alias_index += 1
148-
self.app.alias_entries.append(entry)
149-
self.app.alias_container.mount(entry)
149+
self.app.alias_entries.append(entry) # type: ignore
150+
self.app.alias_container.mount(entry) # type: ignore
150151

151-
self.app.add_alias_entry = stub_add_alias_entry
152+
self.app.add_alias_entry = stub_add_alias_entry # type: ignore
152153
initial_count = len(self.app.alias_entries)
153154
self.app.add_alias_entry()
154155
self.assertEqual(len(self.app.alias_entries), initial_count + 1)
@@ -354,18 +355,18 @@ def stub_add_social_entry(value):
354355
entry = self.StubSocialEntry()
355356
entry.index = self.app.social_index
356357
self.app.social_index += 1
357-
self.app.social_entries.append(entry)
358-
self.app.social_container.mount(entry)
358+
self.app.social_entries.append(entry) # type: ignore
359+
self.app.social_container.mount(entry) # type: ignore
359360

360361
def stub_add_alias_entry():
361362
entry = self.StubAliasEntry()
362363
entry.index = self.app.alias_index
363364
self.app.alias_index += 1
364-
self.app.alias_entries.append(entry)
365-
self.app.alias_container.mount(entry)
365+
self.app.alias_entries.append(entry) # type: ignore
366+
self.app.alias_container.mount(entry) # type: ignore
366367

367-
self.app.add_social_entry = stub_add_social_entry
368-
self.app.add_alias_entry = stub_add_alias_entry
368+
self.app.add_social_entry = stub_add_social_entry # type: ignore
369+
self.app.add_alias_entry = stub_add_alias_entry # type: ignore
369370
self.app.add_social_entry("")
370371
self.app.add_alias_entry()
371372
self.app.clear_form()
@@ -411,18 +412,18 @@ def stub_add_social_entry(value):
411412
entry = self.StubSocialEntry()
412413
entry.index = self.app.social_index
413414
self.app.social_index += 1
414-
self.app.social_entries.append(entry)
415-
self.app.social_container.mount(entry)
415+
self.app.social_entries.append(entry) # type: ignore
416+
self.app.social_container.mount(entry) # type: ignore
416417

417418
def stub_add_alias_entry():
418419
entry = self.StubAliasEntry()
419420
entry.index = self.app.alias_index
420421
self.app.alias_index += 1
421-
self.app.alias_entries.append(entry)
422-
self.app.alias_container.mount(entry)
422+
self.app.alias_entries.append(entry) # type: ignore
423+
self.app.alias_container.mount(entry) # type: ignore
423424

424-
self.app.add_social_entry = stub_add_social_entry
425-
self.app.add_alias_entry = stub_add_alias_entry
425+
self.app.add_social_entry = stub_add_social_entry # type: ignore
426+
self.app.add_alias_entry = stub_add_alias_entry # type: ignore
426427
# Patch clear_form to avoid resetting stubs
427428
self.app.clear_form = lambda: None # type: ignore
428429
load_file_into_form(self.app, "fake.md")
@@ -468,9 +469,9 @@ def test_main_runs_app(
468469
mock_get_repo.assert_called_once()
469470
mock_fork_repo.assert_called_once()
470471
mock_member_app.assert_called_once_with(
471-
unittest.mock.ANY,
472-
unittest.mock.ANY,
473-
unittest.mock.ANY,
474-
unittest.mock.ANY,
472+
ANY,
473+
ANY,
474+
ANY,
475+
ANY,
475476
)
476477
mock_app_instance.run.assert_called_once()

0 commit comments

Comments
 (0)