Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use pre-commit for linting #607

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
21 changes: 0 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,6 @@ jobs:
# because we monkeypatch typing under some circumstances.
python -c 'import typing_extensions; import test.__main__' test_typing -v

linting:
name: Lint

# no reason to run this as a cron job
if: github.event_name != 'schedule'

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3"
cache: "pip"
cache-dependency-path: "test-requirements.txt"
- name: Install dependencies
run: pip install -r test-requirements.txt
- name: Lint implementation
run: ruff check

create-issue-on-failure:
name: Create an issue if daily tests failed
runs-on: ubuntu-latest
Expand Down
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.6
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-yaml
- id: check-toml
- id: check-merge-conflict
- id: check-case-conflict
- id: forbid-submodules
- id: mixed-line-ending
args: [--fix=lf]
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.33.0
hooks:
- id: check-dependabot
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.24.1
hooks:
- id: validate-pyproject
additional_dependencies: ["validate-pyproject-schema-store[all]"]
- repo: https://github.com/rhysd/actionlint
rev: v1.7.7
hooks:
- id: actionlint
- repo: meta
hooks:
- id: check-hooks-apply
1 change: 0 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ build:

sphinx:
configuration: doc/conf.py

25 changes: 25 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,31 @@ Running these commands in the `src/` directory ensures that the local file
`typing_extensions.py` is used, instead of any other version of the library you
may have installed.

# Linting

Linting is done via pre-commit. We recommend running pre-commit via a tool such
as [uv](https://docs.astral.sh/uv/) or [pipx](https://pipx.pypa.io/stable/) so
that pre-commit and its dependencies are installed into an isolated environment
located outside your `typing_extensions` clone. Running pre-commit this way
ensures that you don't accidentally install a version of `typing_extensions`
from PyPI into a virtual environment inside your `typing_extensions` clone,
which could easily happen if pre-commit depended (directly or indirectly) on
`typing_extensions`. If a version of `typing_extensions` from PyPI *was*
installed into a project-local virtual environment, it could lead to
unpredictable results when running `typing_extensions` tests locally.

To run the linters using uv:

```
uvx pre-commit run -a
```

Or using pipx:

```
pipx run pre-commit run -a
```

# Workflow for PyPI releases

- Make sure you follow the versioning policy in the documentation
Expand Down
70 changes: 35 additions & 35 deletions doc/make.bat
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the line endings have changed in this file; there are no other changes

Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
if "%1" == "" goto help
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
1 change: 0 additions & 1 deletion test-requirements.txt

This file was deleted.

Loading