Skip to content

Commit

Permalink
Merge branch 'main' into 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Spitfire1900 authored Sep 22, 2023
2 parents 541de75 + 276a919 commit 519c161
Show file tree
Hide file tree
Showing 23 changed files with 311 additions and 147 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.python-version eol=lf
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
python-version: ["3.7", "3.8", "3.12.0-rc.1"] # no particular need for 3.9 - 3.11
os: [macos-latest, ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.6.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit-autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Detect outdated pre-commit hooks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

- name: Set up Python 3.11
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Run pre-commit
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0

- uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
args: [-i]
types: [python]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
5 changes: 5 additions & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
3.7.9
3.8.10
3.9.13
3.10.11
3.11.5
15 changes: 15 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"recommendations": [
"eeyore.yapf",
"dangmai.workspace-default-settings",
"ms-python.flake8",
"ms-python.isort",
"ms-python.python",
],
// These are remarked as extenstions you should disable for this workspace.
// VSCode does not support disabling extensions via workspace config files.
"unwantedRecommendations": [
"ms-python.black-formatter",
"ms-python.pylint"
]
}
30 changes: 30 additions & 0 deletions .vscode/settings.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"[python]": {
"diffEditor.ignoreTrimWhitespace": false,
"editor.defaultFormatter": "eeyore.yapf",
"editor.formatOnSaveMode": "file",
"editor.formatOnSave": true,
"editor.wordBasedSuggestions": false,
"files.trimTrailingWhitespace": true,
},
"python.analysis.typeCheckingMode": "basic",
"python.languageServer": "Pylance",
"files.exclude": {
"**/*$py.class": true
},
"json.schemas": [
{
"fileMatch": [
"/.vscode/settings.default.json"
],
"url": "vscode://schemas/settings/folder"
}
],
"workspace-default-settings.runOnActivation": true,
"workspace-default-settings.jsonIndentation": 4
}
7 changes: 6 additions & 1 deletion CHANGELOG → CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@
# All notable changes to this project will be documented in this file.
# This project adheres to [Semantic Versioning](http://semver.org/).

## [0.41.0] UNRELEASED
## [0.40.2] 2023-09-22
### Changes
- The verification module has been removed. NOTE: this changes the public APIs
by removing the "verify" parameter.
- Changed FORCE_MULTILINE_DICT to override SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES.
- Adopt pyproject.toml (PEP 517) for build system
### Fixed
- Do not treat variables named `match` as the match keyword.
- Fix SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED for one-item argument lists.
- Fix trailing backslash-newline on Windows when using stdin.

## [0.40.1] 2023-06-20
### Fixed
Expand Down
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ with two exceptions:
The rationale for this is that YAPF was initially developed at Google where
these two exceptions are still part of the internal Python style guide.

## Getting started
YAPF supports using tox 3 for creating a local dev environment, testing, and
building redistributables. See [HACKING.md](HACKING.md) for more info.

```bash
$ pipx run --spec='tox<4' tox --devenv .venv
```

## Small print

Contributions made by corporations are covered by a different agreement than
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Sam Clegg <[email protected]>
Łukasz Langa <[email protected]>
Oleg Butuzov <[email protected]>
Mauricio Herrera Cuadra <[email protected]>
Kyle Gottfried <[email protected]>
82 changes: 82 additions & 0 deletions EDITOR SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Using YAPF with your editor

YAPF is supported by multiple editors via community extensions or plugins.

- [IntelliJ/PyCharm](#intellijpycharm)
- [IPython](#ipython)
- [VSCode](#vscode)

## IntelliJ/PyCharm

Use the `File Watchers` plugin to run YAPF against a file when you perform a save.

1. Install the [File Watchers](https://www.jetbrains.com/help/idea/using-file-watchers.html) Plugin
1. Add the following `.idea/watcherTasks.xml` to your project. If you already have this file just add the `TaskOptions` section from below. This example uses Windows and a virtual environment, modify the `program` option as appropriate.
```xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions">
<TaskOptions isEnabled="true">
<option name="arguments" value="-i $FilePathRelativeToProjectRoot$" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" />
<option name="exitCodeBehavior" value="ERROR" />
<option name="fileExtension" value="py" />
<option name="immediateSync" value="true" />
<option name="name" value="yapf" />
<option name="output" value="" />
<option name="outputFilters">
<array />
</option>
<option name="outputFromStdout" value="false" />
<option name="program" value="$PROJECT_DIR$/.venv/Scripts/yapf.exe" />
<option name="runOnExternalChanges" value="true" />
<option name="scopeName" value="Project Files" />
<option name="trackOnlyRoot" value="false" />
<option name="workingDir" value="$Projectpath$" />
<envs />
</TaskOptions>
</component>
</project>
```

## IPython

IPython supports formatting lines automatically when you press the `<Enter>` button to submit the current code block.

Make sure that the YAPF module is available to the IPython runtime:

```shell
pip install ipython yapf
```

pipx example:

```shell
pipx install ipython
pipx inject ipython yapf
```

Add following to `~/.ipython/profile_default/ipython_config.py`:

```python
c.TerminalInteractiveShell.autoformatter = 'yapf'
```

## VSCode

VSCode has deprecated support for YAPF in its official Python extension [in favor of dedicated formatter extensions](https://github.com/microsoft/vscode-python/wiki/Migration-to-Python-Tools-Extensions).

1. Install EeyoreLee's [yapf](https://marketplace.visualstudio.com/items?itemName=eeyore.yapf) extension.
1. Install the yapf package from pip.
```
pip install yapf
```
1. Add the following to VSCode's `settings.json`:
```jsonc
"[python]": {
"editor.formatOnSaveMode": "file",
"editor.formatOnSave": true,
"editor.defaultFormatter": "eeyore.yapf" # choose this extension
},
```
69 changes: 44 additions & 25 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,64 @@ $ PYTHONPATH=$PWD/yapf python -m yapf -i -r .
$ PYTHONPATH=$PWD/yapf python -m yapf -i $(git diff --name-only @{upstream})
```

## Releasing a new version
## Testing and building redistributables locally

YAPF uses tox 3 to test against multiple python versions and to build redistributables.

- Run tests with Python 3.7 and 3.11:
Tox will opportunistically use pyenv environments when available.
To configure pyenv run the following in bash:

```bash
$ python setup.py test
$ xargs -t -n1 pyenv install < .python-version
```

- Bump version in `setup.py`.

- Build source distribution:
Test against all supported Python versions that are currently installed:
```bash
$ pipx run --spec='tox<4' tox
```

Build and test the sdist and wheel against your default Python environment. The redistributables will be in the `dist` directory.
```bash
$ python setup.py sdist
$ pipx run --spec='tox<4' tox -e bdist_wheel -e sdist
```

- Check that it looks OK.
- Install it onto a virtualenv,
- run tests, and
- run yapf as a tool.
## Releasing a new version

- Build release:
1. Install all expected pyenv environements
```bash
$ xargs -t -n1 pyenv install < .python-version
```

```bash
$ python setup.py sdist bdist_wheel
```
1. Run tests against Python 3.7 - 3.11 with
```bash
$ pipx run --spec='tox<4' tox
```

- Push to PyPI:
1. Bump version in `pyproject.toml`.

```bash
$ twine upload dist/*
```
1. Build and test redistributables

```bash
$ pipx run --spec='tox<4' tox -e bdist_wheel -e sdist
```

1. Check that it looks OK.
1. Install it onto a virtualenv,
1. run tests, and
1. run yapf as a tool.

- Test in a clean virtualenv that 'pip install yapf' works with the new
1. Push to PyPI:

```bash
$ pipx run twine upload dist/*
```

1. Test in a clean virtualenv that 'pip install yapf' works with the new
version.

- Commit the version bump and add tag with:
1. Commit the version bump and add tag with:

```bash
$ git tag v$(VERSION_NUM)
$ git push --tags
```
```bash
$ git tag v$(VERSION_NUM)
$ git push --tags
```
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include HACKING.md LICENSE AUTHORS CHANGELOG CONTRIBUTING.md CONTRIBUTORS
include HACKING.md LICENSE AUTHORS CHANGELOG.md CONTRIBUTING.md CONTRIBUTORS
include .coveragerc .editorconfig .flake8 plugins/README.md
include plugins/vim/autoload/yapf.vim plugins/vim/plugin/yapf.vim pylintrc
include .style.yapf tox.ini .travis.yml .vimrc
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ optional arguments:
-vv, --verbose print out file names while processing
```

### Using YAPF within your favorite editor
YAPF is supported by multiple editors via community extensions or plugins. See [Editor Support](EDITOR%20SUPPORT.md) for more info.

### Return Codes

Normally YAPF returns zero on successful program termination and non-zero
Expand Down
64 changes: 64 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[build-system]
requires = ["setuptools>=58.5.0"]
build-backend = "setuptools.build_meta"

[project]
name = "yapf"
description = "A formatter for Python code"
authors = [{ name = "Google Inc." }]
maintainers = [{ name = "Bill Wendling", email = "[email protected]" }]
license = { file = "LICENSE" }
readme = "README.md"
requires-python = ">=3.7"
version = "0.40.2"
classifiers = [
'Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Software Development :: Quality Assurance',
]
dependencies = [
'importlib-metadata>=6.6.0',
'platformdirs>=3.5.1',
'tomli>=2.0.1',
]

[project.scripts]
yapf = "yapf:run_main"
yapf-diff = "yapf_third_party.yapf_diff.yapf_diff:main"

[project.urls]
# https://daniel.feldroy.com/posts/2023-08-pypi-project-urls-cheatsheet
Home = 'https://github.com/google/yapf'
Changelog = 'https://github.com/google/yapf/blob/main/CHANGELOG.md'
Docs = 'https://github.com/google/yapf/blob/main/README.md#yapf'
Issues = 'https://github.com/google/yapf/issues'

[tool.distutils.bdist_wheel]
python_tag = "py3"

[tool.setuptools]
include-package-data = true
package-dir = { yapf_third_party = 'third_party/yapf_third_party' }

[tool.setuptools.packages.find]
where = [".", 'third_party']
include = ["yapf*", 'yapftests*']

[tool.setuptools.package-data]
yapf_third_party = [
'yapf_diff/LICENSE',
'_ylib2to3/Grammar.txt',
'_ylib2to3/PatternGrammar.txt',
'_ylib2to3/LICENSE',
]
Loading

0 comments on commit 519c161

Please sign in to comment.