Skip to content

Commit

Permalink
Feature: allow calling python -m subliminal (#1197)
Browse files Browse the repository at this point in the history
* Add __main__.py for using with python -m

* ruff unfixable T201-print

---------

Co-authored-by: getzze <getzze@gmail.com>
  • Loading branch information
glensc and getzze authored Dec 16, 2024
1 parent da2817d commit b8853ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ ignore = [
"D107", # Missing docstring in `__init__`
"D401", # First line should be in imperative mood
]
unfixable = [
"T201",
]

[tool.ruff.lint.per-file-ignores]
"docs/conf*.py" = ["ALL"]
Expand Down
26 changes: 26 additions & 0 deletions src/subliminal/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Module subliminal."""

from __future__ import annotations

from textwrap import dedent

if not (__name__ == '__main__' and __package__ == 'subliminal'):
import sys

print( # noqa: T201
dedent(
f"""
The '__main__' module does not seem to have been run in the context
of a runnable package ... did you forget to add the '-m' flag?
Usage: {sys.executable} -m subliminal {' '.join(sys.argv[1:])}
"""
)
)
sys.exit(2)

from subliminal.cli import cli

cli()

0 comments on commit b8853ee

Please sign in to comment.