Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add __main__.py for using with python -m #1197

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading