mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-19 14:49:15 +00:00
Review and more cleanup
This commit is contained in:
parent
d7624ba08d
commit
57b460e5c9
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -28,7 +28,7 @@ # PLEASE FOLLOW THE GUIDE BELOW
|
||||||
### Before submitting a *pull request* make sure you have:
|
### Before submitting a *pull request* make sure you have:
|
||||||
- [ ] At least skimmed through [contributing guidelines](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#developer-instructions) including [yt-dlp coding conventions](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#yt-dlp-coding-conventions)
|
- [ ] At least skimmed through [contributing guidelines](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#developer-instructions) including [yt-dlp coding conventions](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#yt-dlp-coding-conventions)
|
||||||
- [ ] [Searched](https://github.com/yt-dlp/yt-dlp/search?q=is%3Apr&type=Issues) the bugtracker for similar pull requests
|
- [ ] [Searched](https://github.com/yt-dlp/yt-dlp/search?q=is%3Apr&type=Issues) the bugtracker for similar pull requests
|
||||||
- [ ] Checked the code with [ruff](https://docs.astral.sh/ruff/) and [ran relevant tests](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#developer-instructions)
|
- [ ] Checked the code using `hatch run check` (or ran `hatch run install` before committing) and [ran relevant tests](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#developer-instructions)
|
||||||
|
|
||||||
### In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under [Unlicense](http://unlicense.org/). Check all of the following options that apply:
|
### In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under [Unlicense](http://unlicense.org/). Check all of the following options that apply:
|
||||||
- [ ] I am the original author of this code and I am willing to release it under [Unlicense](http://unlicense.org/)
|
- [ ] I am the original author of this code and I am willing to release it under [Unlicense](http://unlicense.org/)
|
||||||
|
|
4
.github/workflows/quick-test.yml
vendored
4
.github/workflows/quick-test.yml
vendored
|
@ -32,4 +32,6 @@ jobs:
|
||||||
- name: Make lazy extractors
|
- name: Make lazy extractors
|
||||||
run: python3 ./devscripts/make_lazy_extractors.py
|
run: python3 ./devscripts/make_lazy_extractors.py
|
||||||
- name: Run ruff
|
- name: Run ruff
|
||||||
run: ruff check . --output-format github
|
run: ruff check --output-format github .
|
||||||
|
- name: Run autopep8
|
||||||
|
run: autopep8 --diff .
|
||||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -64,7 +64,7 @@ cookies
|
||||||
# Python
|
# Python
|
||||||
*.pyc
|
*.pyc
|
||||||
*.pyo
|
*.pyo
|
||||||
.pytest_cache
|
.*_cache
|
||||||
wine-py2exe/
|
wine-py2exe/
|
||||||
py2exe.log
|
py2exe.log
|
||||||
build/
|
build/
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
repos:
|
repos:
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: linter
|
- id: check
|
||||||
name: linter
|
name: code check
|
||||||
entry: hatch run lint
|
entry: hatch run check
|
||||||
language: system
|
|
||||||
types: [python]
|
|
||||||
- id: format
|
|
||||||
name: format
|
|
||||||
entry: hatch run format --diff
|
|
||||||
language: system
|
language: system
|
||||||
types: [python]
|
types: [python]
|
||||||
|
|
|
@ -134,9 +134,7 @@ ### Is the website primarily used for piracy?
|
||||||
|
|
||||||
# DEVELOPER INSTRUCTIONS
|
# DEVELOPER INSTRUCTIONS
|
||||||
|
|
||||||
Most users do not need to build yt-dlp and can [download the builds](https://github.com/yt-dlp/yt-dlp/releases) or get them via [the other installation methods](README.md#installation).
|
Most users do not need to build yt-dlp and can [download the builds](https://github.com/yt-dlp/yt-dlp/releases) or get them via [the other installation methods](README.md#installation). Alternatively, simply execute
|
||||||
|
|
||||||
To quickly run yt-dlp as a developer, you don't need to build anything either. Simply execute
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ python -m yt_dlp
|
$ python -m yt_dlp
|
||||||
|
@ -159,7 +157,7 @@ # DEVELOPER INSTRUCTIONS
|
||||||
$ hatch run tests core
|
$ hatch run tests core
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also run tests for all installed python versions sequentially by setting the `TEST_ALL` variable, like so:
|
You can also run tests for all installed and supported python versions sequentially by setting the `TEST_ALL` variable, like so:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ TEST_ALL=1 hatch run tests core
|
$ TEST_ALL=1 hatch run tests core
|
||||||
|
@ -249,11 +247,10 @@ ## Adding support for a new site
|
||||||
1. Make sure your code follows [yt-dlp coding conventions](#yt-dlp-coding-conventions), passes [ruff](https://docs.astral.sh/ruff/tutorial/#getting-started) code checks and is properly formatted:
|
1. Make sure your code follows [yt-dlp coding conventions](#yt-dlp-coding-conventions), passes [ruff](https://docs.astral.sh/ruff/tutorial/#getting-started) code checks and is properly formatted:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ hatch run lint
|
$ hatch run check
|
||||||
$ hatch run format
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can use `hatch run lint --fix` to automatically fix problems.
|
You can use `hatch run lint` and `hatch run format` to automatically fix problems.
|
||||||
|
|
||||||
1. Make sure your code works under all [Python](https://www.python.org/) versions supported by yt-dlp, namely CPython and PyPy for Python 3.8 and above. Backward compatibility is not required for even older versions of Python.
|
1. Make sure your code works under all [Python](https://www.python.org/) versions supported by yt-dlp, namely CPython and PyPy for Python 3.8 and above. Backward compatibility is not required for even older versions of Python.
|
||||||
1. When the tests pass, [add](https://git-scm.com/docs/git-add) the new files, [commit](https://git-scm.com/docs/git-commit) them and [push](https://git-scm.com/docs/git-push) the result, like this:
|
1. When the tests pass, [add](https://git-scm.com/docs/git-add) the new files, [commit](https://git-scm.com/docs/git-commit) them and [push](https://git-scm.com/docs/git-push) the result, like this:
|
||||||
|
|
9
Makefile
9
Makefile
|
@ -10,7 +10,7 @@ tar: yt-dlp.tar.gz
|
||||||
# intended use: when building a source distribution,
|
# intended use: when building a source distribution,
|
||||||
# make pypi-files && python3 -m build -sn .
|
# make pypi-files && python3 -m build -sn .
|
||||||
pypi-files: AUTHORS Changelog.md LICENSE README.md README.txt supportedsites \
|
pypi-files: AUTHORS Changelog.md LICENSE README.md README.txt supportedsites \
|
||||||
completions yt-dlp.1 pyproject.toml setup.cfg devscripts/* test/*
|
completions yt-dlp.1 pyproject.toml devscripts/* test/*
|
||||||
|
|
||||||
.PHONY: all clean install test tar pypi-files completions ot offlinetest codetest supportedsites
|
.PHONY: all clean install test tar pypi-files completions ot offlinetest codetest supportedsites
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ clean-dist:
|
||||||
yt_dlp/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp yt-dlp yt-dlp.exe yt_dlp.egg-info/ AUTHORS
|
yt_dlp/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp yt-dlp yt-dlp.exe yt_dlp.egg-info/ AUTHORS
|
||||||
clean-cache:
|
clean-cache:
|
||||||
find . \( \
|
find . \( \
|
||||||
-type d -name .pytest_cache -o -type d -name __pycache__ -o -name "*.pyc" -o -name "*.class" \
|
-type d -name '.*_cache' -o -type d -name __pycache__ -o -name "*.pyc" -o -name "*.class" \
|
||||||
\) -prune -exec rm -rf {} \;
|
\) -prune -exec rm -rf {} \;
|
||||||
|
|
||||||
completion-bash: completions/bash/yt-dlp
|
completion-bash: completions/bash/yt-dlp
|
||||||
|
@ -65,6 +65,7 @@ uninstall:
|
||||||
|
|
||||||
codetest:
|
codetest:
|
||||||
ruff check .
|
ruff check .
|
||||||
|
autopep8 --diff .
|
||||||
|
|
||||||
test:
|
test:
|
||||||
$(PYTHON) -m pytest
|
$(PYTHON) -m pytest
|
||||||
|
@ -139,13 +140,13 @@ yt-dlp.tar.gz: all
|
||||||
--exclude '*.pyo' \
|
--exclude '*.pyo' \
|
||||||
--exclude '*~' \
|
--exclude '*~' \
|
||||||
--exclude '__pycache__' \
|
--exclude '__pycache__' \
|
||||||
--exclude '.pytest_cache' \
|
--exclude '.*_cache' \
|
||||||
--exclude '.git' \
|
--exclude '.git' \
|
||||||
-- \
|
-- \
|
||||||
README.md supportedsites.md Changelog.md LICENSE \
|
README.md supportedsites.md Changelog.md LICENSE \
|
||||||
CONTRIBUTING.md Collaborators.md CONTRIBUTORS AUTHORS \
|
CONTRIBUTING.md Collaborators.md CONTRIBUTORS AUTHORS \
|
||||||
Makefile yt-dlp.1 README.txt completions .gitignore \
|
Makefile yt-dlp.1 README.txt completions .gitignore \
|
||||||
setup.cfg yt-dlp yt_dlp pyproject.toml devscripts test
|
yt-dlp yt_dlp pyproject.toml devscripts test
|
||||||
|
|
||||||
AUTHORS:
|
AUTHORS:
|
||||||
git shortlog -s -n HEAD | cut -f2 | sort > AUTHORS
|
git shortlog -s -n HEAD | cut -f2 | sort > AUTHORS
|
||||||
|
|
|
@ -32,7 +32,7 @@ def run_tests(*tests, pattern=None, ci=False):
|
||||||
if pattern:
|
if pattern:
|
||||||
arguments.extend(['-k', pattern])
|
arguments.extend(['-k', pattern])
|
||||||
if run_core:
|
if run_core:
|
||||||
arguments.extend(['--ignore', 'test/test_download.py'])
|
arguments.extend(['-m', 'not download'])
|
||||||
elif run_download:
|
elif run_download:
|
||||||
arguments.extend(['test/test_download.py'])
|
arguments.extend(['test/test_download.py'])
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -62,7 +62,7 @@ build = [
|
||||||
"wheel",
|
"wheel",
|
||||||
]
|
]
|
||||||
dev = [
|
dev = [
|
||||||
"autopep8",
|
"autopep8~=2.0",
|
||||||
"pre-commit",
|
"pre-commit",
|
||||||
"pytest",
|
"pytest",
|
||||||
"ruff==0.2.1",
|
"ruff==0.2.1",
|
||||||
|
@ -82,27 +82,6 @@ yt-dlp = "yt_dlp:main"
|
||||||
[project.entry-points.pyinstaller40]
|
[project.entry-points.pyinstaller40]
|
||||||
hook-dirs = "yt_dlp.__pyinstaller:get_hook_dirs"
|
hook-dirs = "yt_dlp.__pyinstaller:get_hook_dirs"
|
||||||
|
|
||||||
[tool.hatch.envs.default]
|
|
||||||
dependencies = ["yt-dlp[dev]"]
|
|
||||||
|
|
||||||
[tool.hatch.envs.default.scripts]
|
|
||||||
install = "pre-commit install"
|
|
||||||
lint = "ruff check {args:.}"
|
|
||||||
format = "autopep8 {args:--in-place .}"
|
|
||||||
tests = "python -m devscripts.run_tests {args}"
|
|
||||||
|
|
||||||
[[tool.hatch.envs.default.overrides.env.TEST_ALL.matrix.value]]
|
|
||||||
python = [
|
|
||||||
"3.8",
|
|
||||||
"3.9",
|
|
||||||
"3.10",
|
|
||||||
"3.11",
|
|
||||||
"3.12",
|
|
||||||
"pypy3.8",
|
|
||||||
"pypy3.9",
|
|
||||||
"pypy3.10",
|
|
||||||
]
|
|
||||||
|
|
||||||
[tool.hatch.build.targets.sdist]
|
[tool.hatch.build.targets.sdist]
|
||||||
include = [
|
include = [
|
||||||
"/yt_dlp",
|
"/yt_dlp",
|
||||||
|
@ -113,7 +92,6 @@ include = [
|
||||||
"/LICENSE", # included as license
|
"/LICENSE", # included as license
|
||||||
"/pyproject.toml", # included by default
|
"/pyproject.toml", # included by default
|
||||||
"/README.md", # included as readme
|
"/README.md", # included as readme
|
||||||
"/setup.cfg",
|
|
||||||
"/supportedsites.md",
|
"/supportedsites.md",
|
||||||
]
|
]
|
||||||
exclude = ["/yt_dlp/__pyinstaller"]
|
exclude = ["/yt_dlp/__pyinstaller"]
|
||||||
|
@ -141,6 +119,31 @@ artifacts = ["/yt_dlp/extractor/lazy_extractors.py"]
|
||||||
path = "yt_dlp/version.py"
|
path = "yt_dlp/version.py"
|
||||||
pattern = "_pkg_version = '(?P<version>[^']+)'"
|
pattern = "_pkg_version = '(?P<version>[^']+)'"
|
||||||
|
|
||||||
|
[tool.hatch.envs.default]
|
||||||
|
features = ["dev"]
|
||||||
|
|
||||||
|
[tool.hatch.envs.default.scripts]
|
||||||
|
install = "pre-commit install"
|
||||||
|
lint = "ruff check {args:.}"
|
||||||
|
format = "autopep8 --in-place {args:.}"
|
||||||
|
check = [
|
||||||
|
"ruff check --no-fix {args:.}",
|
||||||
|
"autopep8 --diff {args:.}",
|
||||||
|
]
|
||||||
|
tests = "python -m devscripts.run_tests {args}"
|
||||||
|
|
||||||
|
[[tool.hatch.envs.default.overrides.env.TEST_ALL.matrix.value]]
|
||||||
|
python = [
|
||||||
|
"3.8",
|
||||||
|
"3.9",
|
||||||
|
"3.10",
|
||||||
|
"3.11",
|
||||||
|
"3.12",
|
||||||
|
"pypy3.8",
|
||||||
|
"pypy3.9",
|
||||||
|
"pypy3.10",
|
||||||
|
]
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
required-version = "0.2.1"
|
required-version = "0.2.1"
|
||||||
line-length = 120
|
line-length = 120
|
||||||
|
@ -156,7 +159,7 @@ select = [
|
||||||
"E", # pycodestyle errors
|
"E", # pycodestyle errors
|
||||||
"W", # pycodestyle warnings
|
"W", # pycodestyle warnings
|
||||||
"F", # pyflakes
|
"F", # pyflakes
|
||||||
"I", # import order
|
# "I", # import order
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff.lint.per-file-ignores]
|
[tool.ruff.lint.per-file-ignores]
|
||||||
|
@ -173,7 +176,48 @@ relative-imports-order = "closest-to-furthest"
|
||||||
[tool.autopep8]
|
[tool.autopep8]
|
||||||
max_line_length = 120
|
max_line_length = 120
|
||||||
recursive = true
|
recursive = true
|
||||||
|
exit-code = true
|
||||||
jobs = 0
|
jobs = 0
|
||||||
|
select = [
|
||||||
|
"E11",
|
||||||
|
"E121",
|
||||||
|
"E122",
|
||||||
|
"E123",
|
||||||
|
"E124",
|
||||||
|
"E125",
|
||||||
|
"E126",
|
||||||
|
"E127",
|
||||||
|
"E128",
|
||||||
|
"E129",
|
||||||
|
"E131",
|
||||||
|
"E133",
|
||||||
|
"E20",
|
||||||
|
"E211",
|
||||||
|
"E22",
|
||||||
|
"E224",
|
||||||
|
"E225",
|
||||||
|
"E226",
|
||||||
|
"E227",
|
||||||
|
"E228",
|
||||||
|
"E231",
|
||||||
|
"E241",
|
||||||
|
"E242",
|
||||||
|
"E251",
|
||||||
|
"E252",
|
||||||
|
"E26",
|
||||||
|
"E265",
|
||||||
|
"E266",
|
||||||
|
"E27",
|
||||||
|
"E301",
|
||||||
|
"E302",
|
||||||
|
"E303",
|
||||||
|
"E304",
|
||||||
|
"E305",
|
||||||
|
"E306",
|
||||||
|
"E502",
|
||||||
|
"W391",
|
||||||
|
"W504",
|
||||||
|
]
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
addopts = "-ra -v --strict-markers"
|
addopts = "-ra -v --strict-markers"
|
||||||
|
|
Loading…
Reference in a new issue