Skip to content

Commit 973b17e

Browse files
Merge pull request #5 from python-thread/dev
Style: Ruff formatting
2 parents 5f8802a + 77a02d0 commit 973b17e

File tree

7 files changed

+203
-128
lines changed

7 files changed

+203
-128
lines changed

ruff.toml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
indent-width = 2
2+
3+
[format]
4+
# Exclude commonly ignored directories.
5+
exclude = [
6+
".bzr",
7+
".direnv",
8+
".eggs",
9+
".git",
10+
".git-rewrite",
11+
".hg",
12+
".ipynb_checkpoints",
13+
".mypy_cache",
14+
".nox",
15+
".pants.d",
16+
".pyenv",
17+
".pytest_cache",
18+
".pytype",
19+
".ruff_cache",
20+
".svn",
21+
".tox",
22+
".venv",
23+
".vscode",
24+
"__pypackages__",
25+
"_build",
26+
"buck-out",
27+
"build",
28+
"dist",
29+
"node_modules",
30+
"site-packages",
31+
"venv",
32+
]
33+
34+
indent-style = "space"
35+
line-ending = "lf"
36+
quote-style = "single"
37+
docstring-code-format = true
38+
39+
40+
[lint]
41+
# Avoid enforcing line-length violations (`E501`)
42+
ignore = ["E501"]
43+
44+
# Allow unused variables when underscore-prefixed.
45+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
46+
47+
48+
# Ignore `E402` (import violations) in all `__init__.py` files, and in select subdirectories.
49+
[lint.per-file-ignores]
50+
"__init__.py" = ["E402", "F401"]
51+
"**/__init__.py" = ["E402", "F401"]
52+
"**/{tests,docs,tools}/*" = ["E402"]

src/thread-cli/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
Copyright (c) 2020, thread.ngjx.org. All rights reserved.
1111
"""
1212

13-
__version__ = "0.1.0"
13+
__version__ = '0.1.0'
1414
from .utils.logging import ColorLogger, logging
1515

1616
# Export Core
1717
from .base import cli_base as app
1818
from .process import process as process_cli
1919

2020
app.command(
21-
name="process",
21+
name='process',
2222
no_args_is_help=True,
23-
context_settings={"allow_extra_args": True},
23+
context_settings={'allow_extra_args': True},
2424
)(process_cli)
2525

2626

@@ -29,4 +29,4 @@
2929

3030

3131
# Wildcard export
32-
__all__ = ["app"]
32+
__all__ = ['app']

src/thread-cli/base.py

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33

44
from . import __version__
55
from .utils import DebugOption, VerboseOption, QuietOption, verbose_args_processor
6+
67
logger = logging.getLogger('base')
78

89

910
cli_base = typer.Typer(
10-
no_args_is_help = True,
11-
rich_markup_mode = 'rich',
12-
context_settings = {
13-
'help_option_names': ['-h', '--help', 'help']
14-
}
11+
no_args_is_help=True,
12+
rich_markup_mode='rich',
13+
context_settings={'help_option_names': ['-h', '--help', 'help']},
1514
)
1615

1716

@@ -21,19 +20,19 @@ def version_callback(value: bool):
2120
raise typer.Exit()
2221

2322

24-
@cli_base.callback(invoke_without_command = True)
23+
@cli_base.callback(invoke_without_command=True)
2524
def callback(
2625
version: bool = typer.Option(
27-
None, '--version',
28-
callback = version_callback,
29-
help = 'Get the current installed version',
30-
is_eager = True
26+
None,
27+
'--version',
28+
callback=version_callback,
29+
help='Get the current installed version',
30+
is_eager=True,
3131
),
32-
3332
debug: bool = DebugOption,
3433
verbose: bool = VerboseOption,
35-
quiet: bool = QuietOption
36-
):
34+
quiet: bool = QuietOption,
35+
):
3736
"""
3837
[b]Thread CLI[/b]\b\n
3938
[white]Use thread from the terminal![/white]
@@ -45,20 +44,17 @@ def callback(
4544
verbose_args_processor(debug, verbose, quiet)
4645

4746

48-
4947
# Help and Others
50-
@cli_base.command(rich_help_panel = 'Help and Others')
48+
@cli_base.command(rich_help_panel='Help and Others')
5149
def help():
5250
"""Get [yellow]help[/yellow] from the community. :question:"""
5351
typer.echo('Feel free to search for or ask questions here!')
5452
try:
5553
logger.info('Attempting to open in web browser...')
5654

5755
import webbrowser
58-
webbrowser.open(
59-
'https://github.com/python-thread/thread/issues',
60-
new = 2
61-
)
56+
57+
webbrowser.open('https://github.com/python-thread/thread/issues', new=2)
6258
typer.echo('Opening in web browser!')
6359

6460
except Exception as e:
@@ -67,17 +63,16 @@ def help():
6763
typer.echo('https://github.com/python-thread/thread/issues')
6864

6965

70-
71-
@cli_base.command(rich_help_panel = 'Help and Others')
66+
@cli_base.command(rich_help_panel='Help and Others')
7267
def docs():
7368
"""View our [yellow]documentation.[/yellow] :book:"""
7469
typer.echo('Thanks for using Thread, here is our documentation!')
7570
try:
7671
logger.info('Attempting to open in web browser...')
7772
import webbrowser
73+
7874
webbrowser.open(
79-
'https://github.com/python-thread/thread/blob/main/docs/command-line.md',
80-
new = 2
75+
'https://github.com/python-thread/thread/blob/main/docs/command-line.md', new=2
8176
)
8277
typer.echo('Opening in web browser!')
8378

@@ -87,18 +82,15 @@ def docs():
8782
typer.echo('https://github.com/python-thread/thread/blob/main/docs/command-line.md')
8883

8984

90-
91-
@cli_base.command(rich_help_panel = 'Help and Others')
85+
@cli_base.command(rich_help_panel='Help and Others')
9286
def report():
9387
"""[yellow]Report[/yellow] an issue. :bug:"""
9488
typer.echo('Sorry you run into an issue, report it here!')
9589
try:
9690
logger.info('Attempting to open in web browser...')
9791
import webbrowser
98-
webbrowser.open(
99-
'https://github.com/python-thread/thread/issues',
100-
new = 2
101-
)
92+
93+
webbrowser.open('https://github.com/python-thread/thread/issues', new=2)
10294
typer.echo('Opening in web browser!')
10395

10496
except Exception as e:
@@ -107,11 +99,10 @@ def report():
10799
typer.echo('https://github.com/python-thread/thread/issues')
108100

109101

110-
111102
# Utils and Configs
112-
@cli_base.command(rich_help_panel = 'Utils and Configs')
103+
@cli_base.command(rich_help_panel='Utils and Configs')
113104
def config(configuration: str):
114105
"""
115106
[blue]Configure[/blue] the system. :wrench:
116107
"""
117-
typer.echo('Coming soon!')
108+
typer.echo('Coming soon!')

0 commit comments

Comments
 (0)