Skip to content

Commit

Permalink
pass tuples to str.startswith() where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Nov 8, 2024
1 parent ac8c611 commit a35f594
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nicegui/favicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_favicon_response() -> Response:


def _is_remote_url(favicon: str) -> bool:
return favicon.startswith('http://') or favicon.startswith('https://')
return favicon.startswith(('http://', 'https://'))


def _is_char(favicon: str) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion website/documentation/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def demo(f: Callable, *, lazy: bool = True, tab: Optional[Union[str, Callable]]
with ui.column().classes('w-full items-stretch gap-8 no-wrap min-[1500px]:flex-row'):
code = inspect.getsource(f).split('# END OF DEMO', 1)[0].strip().splitlines()
code = [line for line in code if not line.endswith('# HIDE')]
while not code[0].strip().startswith('def') and not code[0].strip().startswith('async def'):
while not code[0].strip().startswith(('def', 'async def')):
del code[0]
del code[0]
if code[0].strip().startswith('"""'):
Expand Down
3 changes: 1 addition & 2 deletions website/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class Example:
def __post_init__(self) -> None:
"""Post-initialization hook."""
name = self.title.lower().replace(' ', '_')
content = [p for p in (PATH / name).glob('*')
if not any(p.name.startswith(ignore) for ignore in ['__pycache__', '.', 'test_'])]
content = [p for p in (PATH / name).glob('*') if not p.name.startswith(('__pycache__', '.', 'test_'))]
filename = 'main.py' if len(content) == 1 else ''
self.url = f'https://github.com/zauberzeug/nicegui/tree/main/examples/{name}/{filename}'

Expand Down

0 comments on commit a35f594

Please sign in to comment.