Skip to content

Commit

Permalink
Merge branch 'main' into doc-types
Browse files Browse the repository at this point in the history
  • Loading branch information
EliahKagan committed Mar 14, 2024
2 parents b070e93 + e880c33 commit 0b99041
Show file tree
Hide file tree
Showing 29 changed files with 195 additions and 219 deletions.
26 changes: 0 additions & 26 deletions .flake8

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ jobs:
- uses: pre-commit/[email protected]
with:
extra_args: --all-files --hook-stage manual
env:
SKIP: black-format
27 changes: 6 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
- id: black
alias: black-check
name: black (check)
args: [--check, --diff]
exclude: ^git/ext/
stages: [manual]

- id: black
alias: black-format
name: black (format)
exclude: ^git/ext/

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.9.16
- flake8-comprehensions==3.14.0
- flake8-typing-imports==1.14.0
- id: ruff-format
exclude: ^git/ext/
- id: ruff
args: ["--fix"]
exclude: ^doc|^git/ext/

- repo: https://github.com/shellcheck-py/shellcheck-py
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
.PHONY: all lint clean release force_release
.PHONY: all clean release force_release

all:
@awk -F: '/^[[:alpha:]].*:/ && !/^all:/ {print $$1}' Makefile

lint:
SKIP=black-format pre-commit run --all-files --hook-stage manual

clean:
rm -rf build/ dist/ .eggs/ .tox/

Expand Down
50 changes: 24 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ probably the skills to scratch that itch of mine: implement `git` in a way that
If you like the idea and want to learn more, please head over to [gitoxide](https://github.com/Byron/gitoxide), an
implementation of 'git' in [Rust](https://www.rust-lang.org).

*(Please note that `gitoxide` is not currently available for use in Python, and that Rust is required)*
*(Please note that `gitoxide` is not currently available for use in Python, and that Rust is required.)*

## GitPython

Expand All @@ -39,9 +39,9 @@ The project is open to contributions of all kinds, as well as new maintainers.

### REQUIREMENTS

GitPython needs the `git` executable to be installed on the system and available in your `PATH` for most operations.
If it is not in your `PATH`, you can help GitPython find it by setting
the `GIT_PYTHON_GIT_EXECUTABLE=<path/to/git>` environment variable.
GitPython needs the `git` executable to be installed on the system and available in your
`PATH` for most operations. If it is not in your `PATH`, you can help GitPython find it
by setting the `GIT_PYTHON_GIT_EXECUTABLE=<path/to/git>` environment variable.

- Git (1.7.x or newer)
- Python >= 3.7
Expand All @@ -57,7 +57,7 @@ GitPython and its required package dependencies can be installed in any of the f

To obtain and install a copy [from PyPI](https://pypi.org/project/GitPython/), run:

```bash
```sh
pip install GitPython
```

Expand All @@ -67,15 +67,15 @@ pip install GitPython

If you have downloaded the source code, run this from inside the unpacked `GitPython` directory:

```bash
```sh
pip install .
```

#### By cloning the source code repository

To clone the [the GitHub repository](https://github.com/gitpython-developers/GitPython) from source to work on the code, you can do it like so:

```bash
```sh
git clone https://github.com/gitpython-developers/GitPython
cd GitPython
./init-tests-after-clone.sh
Expand All @@ -85,15 +85,15 @@ On Windows, `./init-tests-after-clone.sh` can be run in a Git Bash shell.

If you are cloning [your own fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks), then replace the above `git clone` command with one that gives the URL of your fork. Or use this [`gh`](https://cli.github.com/) command (assuming you have `gh` and your fork is called `GitPython`):

```bash
```sh
gh repo clone GitPython
```

Having cloned the repo, create and activate your [virtual environment](https://docs.python.org/3/tutorial/venv.html).

Then make an [editable install](https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs):

```bash
```sh
pip install -e ".[test]"
```

Expand All @@ -105,7 +105,7 @@ In rare cases, you may want to work on GitPython and one or both of its [gitdb](

If you want to do that *and* you want the versions in GitPython's git submodules to be used, then pass `-e git/ext/gitdb` and/or `-e git/ext/gitdb/gitdb/ext/smmap` to `pip install`. This can be done in any order, and in separate `pip install` commands or the same one, so long as `-e` appears before *each* path. For example, you can install GitPython, gitdb, and smmap editably in the currently active virtual environment this way:

```bash
```sh
pip install -e ".[test]" -e git/ext/gitdb -e git/ext/gitdb/gitdb/ext/smmap
```

Expand Down Expand Up @@ -141,53 +141,51 @@ you will encounter test failures.

Ensure testing libraries are installed. This is taken care of already if you installed with:

```bash
```sh
pip install -e ".[test]"
```

Otherwise, you can run:

```bash
pip install -r test-requirements.txt
```
If you had installed with a command like `pip install -e .` instead, you can still run
the above command to add the testing dependencies.

#### Test commands

To test, run:

```bash
```sh
pytest
```

To lint, and apply automatic code formatting, run:
To lint, and apply some linting fixes as well as automatic code formatting, run:

```bash
```sh
pre-commit run --all-files
```

- Linting without modifying code can be done with: `make lint`
- Auto-formatting without other lint checks can be done with: `black .`
This includes the linting and autoformatting done by Ruff, as well as some other checks.

To typecheck, run:

```bash
```sh
mypy -p git
```

#### CI (and tox)

The same linting, and running tests on all the different supported Python versions, will be performed:
Style and formatting checks, and running tests on all the different supported Python versions, will be performed:

- Upon submitting a pull request.
- On each push, *if* you have a fork with GitHub Actions enabled.
- Locally, if you run [`tox`](https://tox.wiki/) (this skips any Python versions you don't have installed).

#### Configuration files

Specific tools:
Specific tools are all configured in the `./pyproject.toml` file:

- Configurations for `mypy`, `pytest`, `coverage.py`, and `black` are in `./pyproject.toml`.
- Configuration for `flake8` is in the `./.flake8` file.
- `pytest` (test runner)
- `coverage.py` (code coverage)
- `ruff` (linter and formatter)
- `mypy` (type checker)

Orchestration tools:

Expand Down
Loading

0 comments on commit 0b99041

Please sign in to comment.