Skip to content

Commit b8853ee

Browse files
glenscgetzze
andauthored
Feature: allow calling python -m subliminal (#1197)
* Add __main__.py for using with python -m * ruff unfixable T201-print --------- Co-authored-by: getzze <[email protected]>
1 parent da2817d commit b8853ee

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ ignore = [
208208
"D107", # Missing docstring in `__init__`
209209
"D401", # First line should be in imperative mood
210210
]
211+
unfixable = [
212+
"T201",
213+
]
211214

212215
[tool.ruff.lint.per-file-ignores]
213216
"docs/conf*.py" = ["ALL"]

src/subliminal/__main__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""Module subliminal."""
2+
3+
from __future__ import annotations
4+
5+
from textwrap import dedent
6+
7+
if not (__name__ == '__main__' and __package__ == 'subliminal'):
8+
import sys
9+
10+
print( # noqa: T201
11+
dedent(
12+
f"""
13+
14+
The '__main__' module does not seem to have been run in the context
15+
of a runnable package ... did you forget to add the '-m' flag?
16+
17+
Usage: {sys.executable} -m subliminal {' '.join(sys.argv[1:])}
18+
19+
"""
20+
)
21+
)
22+
sys.exit(2)
23+
24+
from subliminal.cli import cli
25+
26+
cli()

0 commit comments

Comments
 (0)