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

sync upstream #4

Merged
merged 58 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f4b5e70
[red-knot] binary arithmetic on instances (#13800)
carljm Oct 19, 2024
55bccf6
[red-knot] Fix edge case for binary-expression inference where the lh…
AlexWaygood Oct 19, 2024
fb66f71
[red-knot] Enhancing Diagnostics for Compare Expression Inference (#1…
cake-monotone Oct 19, 2024
2d2baec
[python_ast] Make the iter_mut functions public (#13542)
ndmitchell Oct 19, 2024
0f0fff4
[red-knot] Implement more types in binary and unary expressions (#13803)
Glyphack Oct 20, 2024
075e378
Update BREAKING_CHANGES.md for Ruff 0.7 (#13828)
AlexWaygood Oct 20, 2024
27c50be
Bump MSRV to Rust 1.80 (#13826)
MichaReiser Oct 20, 2024
7ca3571
Update Rust crate pep440_rs to 0.7.1 (#13654)
renovate[bot] Oct 20, 2024
7fd8e30
[red-knot] Cleanup generated names of mdtest tests (#13831)
Aditya-PS-05 Oct 20, 2024
72adb09
Simplify iteration idioms (#13834)
AlexWaygood Oct 20, 2024
02bca9a
Modernize build scripts (#13837)
AlexWaygood Oct 20, 2024
efa798b
Update dependency mdformat to v0.7.18 (#13843)
renovate[bot] Oct 21, 2024
a5d52b0
Update dependency ruff to v0.7.0 (#13847)
renovate[bot] Oct 21, 2024
c9b74ed
Update Rust crate libc to v0.2.161 (#13840)
renovate[bot] Oct 21, 2024
ca8f108
Update Rust crate anyhow to v1.0.90 (#13839)
renovate[bot] Oct 21, 2024
7060bf8
Update Rust crate proc-macro2 to v1.0.88 (#13841)
renovate[bot] Oct 21, 2024
cf26676
Update Rust crate syn to v2.0.82 (#13842)
renovate[bot] Oct 21, 2024
19a2fd1
Update Rust crate fern to 0.7.0 (#13844)
renovate[bot] Oct 21, 2024
9477058
Update Rust crate serde_json to v1.0.132 (#13848)
renovate[bot] Oct 21, 2024
a80d515
Update Rust crate uuid to v1.11.0 (#13845)
renovate[bot] Oct 21, 2024
28e9950
Update dependency tomli_w to v1.1.0 (#13849)
renovate[bot] Oct 21, 2024
a3a8363
Update pre-commit dependencies (#13850)
renovate[bot] Oct 21, 2024
c2dc502
Update NPM Development dependencies (#13851)
renovate[bot] Oct 21, 2024
f3612c2
[`pylint`] - restrict `iteration-over-set` to only work on sets of li…
diceroll123 Oct 21, 2024
d9ef83b
[red-knot] Consistently rename BoolLiteral => BooleanLiteral (#13856)
sharkdp Oct 21, 2024
fa76261
[red-knot] handle unions on the LHS of is_subtype_of (#13857)
sharkdp Oct 21, 2024
9e3cf14
Speed up mdtests (#13832)
MichaReiser Oct 21, 2024
e9dd921
formatter: Introduce `QuoteMetadata` (#13858)
MichaReiser Oct 21, 2024
a77512d
[red-knot] Improve chained comparisons handling (#13825)
TomerBin Oct 21, 2024
155be88
Speedup mdtest parser (#13835)
MichaReiser Oct 21, 2024
e39110e
Update cloudflare/wrangler-action action to v3.9.0 (#13846)
renovate[bot] Oct 21, 2024
9d10279
[red-knot] Support for not-equal narrowing (#13749)
Lexxxzy Oct 21, 2024
cd6c937
[red-knot] Report line numbers in mdtest relative to the markdown fil…
pilleye Oct 22, 2024
46c0961
[red-knot] is_subtype_of: treat literals as subtype of 'object' (#13876)
sharkdp Oct 22, 2024
7dbd8f0
ci(docker): incorporate docker release enhancements from uv (#13274)
samypr100 Oct 22, 2024
5d4edd6
Fix `D204`'s documentation to correctly mention the conventions when …
MichaReiser Oct 22, 2024
c6ce52c
[red-knot] Treat empty intersection as 'object', fix intersection sim…
sharkdp Oct 22, 2024
f335fe4
[red-knot] rename {Class,Module,Function} => {Class,Module,Function}L…
sharkdp Oct 22, 2024
2f88f84
Alternate quotes for strings inside f-strings in preview (#13860)
MichaReiser Oct 23, 2024
387076d
[red-knot] Use track_caller for expect_ methods (#13884)
sharkdp Oct 23, 2024
4d10951
[`flake8-type-checking`] Support auto-quoting when annotations contai…
Glyphack Oct 23, 2024
00b0782
Fix stale syntax errors in playground (#13888)
MichaReiser Oct 23, 2024
72c18c8
Fix E221 and E222 to flag missing or extra whitespace around `==` ope…
MichaReiser Oct 23, 2024
2c57c2d
[red-knot] Type narrowing for `isinstance` checks (#13894)
sharkdp Oct 23, 2024
de4181d
Remove "default" remark from `ruff check` (#13900)
mihaic Oct 24, 2024
e402e27
Use referencial equality in `traversal` helper methods (#13895)
MichaReiser Oct 24, 2024
73ee72b
Join implicit concatenated strings when they fit on a line (#13663)
MichaReiser Oct 24, 2024
77ae0cc
[red-knot] Infer subscript expression types for bytes literals (#13901)
sharkdp Oct 24, 2024
3eb4546
[red-knot] Format mdtest Python snippets more concisely (#13905)
AlexWaygood Oct 24, 2024
7272f83
Fix preview style name in `can_omit_parentheses` to is_f_string_forma…
MichaReiser Oct 24, 2024
113ce84
Fix `normalize` arguments when `fstring_formatting` is disabled (#13910)
MichaReiser Oct 24, 2024
337af83
Bump version to 0.7.1 (#13913)
dhruvmanila Oct 24, 2024
32b57b2
Enable nursery rules: 'redundant_clone', 'debug_assert_with_mut_call'…
MichaReiser Oct 25, 2024
085a43a
[red-knot] knot benchmark: fix `--knot-path` arg (#13923)
sharkdp Oct 25, 2024
5eb87aa
[red-knot] Infer `Todo`, not `Unknown`, for PEP-604 unions in annotat…
AlexWaygood Oct 25, 2024
6aaf1d9
[red-knot] Remove lint-phase (#13922)
MichaReiser Oct 25, 2024
3006d6d
Docs: Add GitLab CI/CD to integrations. (#13915)
jvacek Oct 26, 2024
35f007f
[red-knot] Type narrow in else clause (#13918)
TomerBin Oct 26, 2024
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
250 changes: 236 additions & 14 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@ on:
paths:
- .github/workflows/build-docker.yml

env:
RUFF_BASE_IMG: ghcr.io/${{ github.repository_owner }}/ruff

jobs:
docker-publish:
name: Build Docker image (ghcr.io/astral-sh/ruff)
docker-build:
name: Build Docker image (ghcr.io/astral-sh/ruff) for ${{ matrix.platform }}
runs-on: ubuntu-latest
environment:
name: release
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -36,12 +45,6 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/astral-sh/ruff

- name: Check tag consistency
if: ${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
run: |
Expand All @@ -55,14 +58,233 @@ jobs:
echo "Releasing ${version}"
fi

- name: "Build and push Docker image"
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.RUFF_BASE_IMG }}
# Defining this makes sure the org.opencontainers.image.version OCI label becomes the actual release version and not the branch name
tags: |
type=raw,value=dry-run,enable=${{ inputs.plan == '' || fromJson(inputs.plan).announcement_tag_is_implicit }}
type=pep440,pattern={{ version }},value=${{ inputs.plan != '' && fromJson(inputs.plan).announcement_tag || 'dry-run' }},enable=${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}

- name: Normalize Platform Pair (replace / with -)
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_TUPLE=${platform//\//-}" >> $GITHUB_ENV

# Adapted from https://docs.docker.com/build/ci/github-actions/multi-platform/
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
cache-from: type=gha,scope=ruff-${{ env.PLATFORM_TUPLE }}
cache-to: type=gha,mode=min,scope=ruff-${{ env.PLATFORM_TUPLE }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.RUFF_BASE_IMG }},push-by-digest=true,name-canonical=true,push=${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}

- name: Export digests
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"

- name: Upload digests
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_TUPLE }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

docker-publish:
name: Publish Docker image (ghcr.io/astral-sh/ruff)
runs-on: ubuntu-latest
environment:
name: release
needs:
- docker-build
if: ${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.RUFF_BASE_IMG }}
# Order is on purpose such that the label org.opencontainers.image.version has the first pattern with the full version
tags: |
type=pep440,pattern={{ version }},value=${{ fromJson(inputs.plan).announcement_tag }}
type=pep440,pattern={{ major }}.{{ minor }},value=${{ fromJson(inputs.plan).announcement_tag }}

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# Adapted from https://docs.docker.com/build/ci/github-actions/multi-platform/
- name: Create manifest list and push
working-directory: /tmp/digests
# The jq command expands the docker/metadata json "tags" array entry to `-t tag1 -t tag2 ...` for each tag in the array
# The printf will expand the base image with the `<RUFF_BASE_IMG>@sha256:<sha256> ...` for each sha256 in the directory
# The final command becomes `docker buildx imagetools create -t tag1 -t tag2 ... <RUFF_BASE_IMG>@sha256:<sha256_1> <RUFF_BASE_IMG>@sha256:<sha256_2> ...`
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.RUFF_BASE_IMG }}@sha256:%s ' *)

docker-publish-extra:
name: Publish additional Docker image based on ${{ matrix.image-mapping }}
runs-on: ubuntu-latest
environment:
name: release
needs:
- docker-publish
if: ${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
strategy:
fail-fast: false
matrix:
# Mapping of base image followed by a comma followed by one or more base tags (comma separated)
# Note, org.opencontainers.image.version label will use the first base tag (use the most specific tag first)
image-mapping:
- alpine:3.20,alpine3.20,alpine
- debian:bookworm-slim,bookworm-slim,debian-slim
- buildpack-deps:bookworm,bookworm,debian
steps:
- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate Dynamic Dockerfile Tags
shell: bash
run: |
set -euo pipefail

# Extract the image and tags from the matrix variable
IFS=',' read -r BASE_IMAGE BASE_TAGS <<< "${{ matrix.image-mapping }}"

# Generate Dockerfile content
cat <<EOF > Dockerfile
FROM ${BASE_IMAGE}
COPY --from=${{ env.RUFF_BASE_IMG }}:latest /ruff /usr/local/bin/ruff
ENTRYPOINT []
CMD ["/usr/local/bin/ruff"]
EOF

# Initialize a variable to store all tag docker metadata patterns
TAG_PATTERNS=""

# Loop through all base tags and append its docker metadata pattern to the list
# Order is on purpose such that the label org.opencontainers.image.version has the first pattern with the full version
IFS=','; for TAG in ${BASE_TAGS}; do
TAG_PATTERNS="${TAG_PATTERNS}type=pep440,pattern={{ version }},suffix=-${TAG},value=${{ fromJson(inputs.plan).announcement_tag }}\n"
TAG_PATTERNS="${TAG_PATTERNS}type=pep440,pattern={{ major }}.{{ minor }},suffix=-${TAG},value=${{ fromJson(inputs.plan).announcement_tag }}\n"
TAG_PATTERNS="${TAG_PATTERNS}type=raw,value=${TAG}\n"
done

# Remove the trailing newline from the pattern list
TAG_PATTERNS="${TAG_PATTERNS%\\n}"

# Export image cache name
echo "IMAGE_REF=${BASE_IMAGE//:/-}" >> $GITHUB_ENV

# Export tag patterns using the multiline env var syntax
{
echo "TAG_PATTERNS<<EOF"
echo -e "${TAG_PATTERNS}"
echo EOF
} >> $GITHUB_ENV

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
# ghcr.io prefers index level annotations
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: index
with:
images: ${{ env.RUFF_BASE_IMG }}
flavor: |
latest=false
tags: |
${{ env.TAG_PATTERNS }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
# Reuse the builder
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
tags: ghcr.io/astral-sh/ruff:latest,ghcr.io/astral-sh/ruff:${{ (inputs.plan != '' && fromJson(inputs.plan).announcement_tag) || 'dry-run' }}
# We do not really need to cache here as the Dockerfile is tiny
#cache-from: type=gha,scope=ruff-${{ env.IMAGE_REF }}
#cache-to: type=gha,mode=min,scope=ruff-${{ env.IMAGE_REF }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}

# This is effectively a duplicate of `docker-publish` to make https://github.com/astral-sh/ruff/pkgs/container/ruff
# show the ruff base image first since GitHub always shows the last updated image digests
# This works by annotating the original digests (previously non-annotated) which triggers an update to ghcr.io
docker-republish:
name: Annotate Docker image (ghcr.io/astral-sh/ruff)
runs-on: ubuntu-latest
environment:
name: release
needs:
- docker-publish-extra
if: ${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: index
with:
images: ${{ env.RUFF_BASE_IMG }}
# Order is on purpose such that the label org.opencontainers.image.version has the first pattern with the full version
tags: |
type=pep440,pattern={{ version }},value=${{ fromJson(inputs.plan).announcement_tag }}
type=pep440,pattern={{ major }}.{{ minor }},value=${{ fromJson(inputs.plan).announcement_tag }}

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

# Adapted from https://docs.docker.com/build/ci/github-actions/multi-platform/
- name: Create manifest list and push
working-directory: /tmp/digests
# The readarray part is used to make sure the quoting and special characters are preserved on expansion (e.g. spaces)
# The jq command expands the docker/metadata json "tags" array entry to `-t tag1 -t tag2 ...` for each tag in the array
# The printf will expand the base image with the `<RUFF_BASE_IMG>@sha256:<sha256> ...` for each sha256 in the directory
# The final command becomes `docker buildx imagetools create -t tag1 -t tag2 ... <RUFF_BASE_IMG>@sha256:<sha256_1> <RUFF_BASE_IMG>@sha256:<sha256_2> ...`
run: |
readarray -t lines <<< "$DOCKER_METADATA_OUTPUT_ANNOTATIONS"; annotations=(); for line in "${lines[@]}"; do annotations+=(--annotation "$line"); done
docker buildx imagetools create \
"${annotations[@]}" \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.RUFF_BASE_IMG }}@sha256:%s ' *)
2 changes: 1 addition & 1 deletion .github/workflows/publish-playground.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
working-directory: playground
- name: "Deploy to Cloudflare Pages"
if: ${{ env.CF_API_TOKEN_EXISTS == 'true' }}
uses: cloudflare/wrangler-action@v3.7.0
uses: cloudflare/wrangler-action@v3.9.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ exclude: |

repos:
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.20.2
rev: v0.21
hooks:
- id: validate-pyproject

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
rev: 0.7.18
hooks:
- id: mdformat
additional_dependencies:
Expand All @@ -46,16 +46,16 @@ repos:
)$

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.19.0
rev: 1.19.1
hooks:
- id: blacken-docs
args: ["--line-length", "130"]
args: ["--pyi", "--line-length", "130"]
files: '^crates/.*/resources/mdtest/.*\.md'
additional_dependencies:
- black==24.10.0

- repo: https://github.com/crate-ci/typos
rev: v1.25.0
rev: v1.26.0
hooks:
- id: typos

Expand All @@ -69,7 +69,7 @@ repos:
pass_filenames: false # This makes it a lot faster

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.7.0
hooks:
- id: ruff-format
- id: ruff
Expand Down
13 changes: 13 additions & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Breaking Changes

## 0.7.0

- The pytest rules `PT001` and `PT023` now default to omitting the decorator parentheses when there are no arguments
([#12838](https://github.com/astral-sh/ruff/pull/12838), [#13292](https://github.com/astral-sh/ruff/pull/13292)).
This was a change that we attempted to make in Ruff v0.6.0, but only partially made due to an error on our part.
See the [blog post](https://astral.sh/blog/ruff-v0.7.0) for more details.
- The `useless-try-except` rule (in our `tryceratops` category) has been recoded from `TRY302` to
`TRY203` ([#13502](https://github.com/astral-sh/ruff/pull/13502)). This ensures Ruff's code is consistent with
the same rule in the [`tryceratops`](https://github.com/guilatrova/tryceratops) linter.
- The `lint.allow-unused-imports` setting has been removed ([#13677](https://github.com/astral-sh/ruff/pull/13677)). Use
[`lint.pyflakes.allow-unused-imports`](https://docs.astral.sh/ruff/settings/#lint_pyflakes_allowed-unused-imports)
instead.

## 0.6.0

- Detect imports in `src` layouts by default for `isort` rules ([#12848](https://github.com/astral-sh/ruff/pull/12848))
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## 0.7.1

### Preview features

- Fix `E221` and `E222` to flag missing or extra whitespace around `==` operator ([#13890](https://github.com/astral-sh/ruff/pull/13890))
- Formatter: Alternate quotes for strings inside f-strings in preview ([#13860](https://github.com/astral-sh/ruff/pull/13860))
- Formatter: Join implicit concatenated strings when they fit on a line ([#13663](https://github.com/astral-sh/ruff/pull/13663))
- \[`pylint`\] Restrict `iteration-over-set` to only work on sets of literals (`PLC0208`) ([#13731](https://github.com/astral-sh/ruff/pull/13731))

### Rule changes

- \[`flake8-type-checking`\] Support auto-quoting when annotations contain quotes ([#11811](https://github.com/astral-sh/ruff/pull/11811))

### Server

- Avoid indexing the workspace for single-file mode ([#13770](https://github.com/astral-sh/ruff/pull/13770))

### Bug fixes

- Make `ARG002` compatible with `EM101` when raising `NotImplementedError` ([#13714](https://github.com/astral-sh/ruff/pull/13714))

### Other changes

- Introduce more Docker tags for Ruff (similar to uv) ([#13274](https://github.com/astral-sh/ruff/pull/13274))

## 0.7.0

Check out the [blog post](https://astral.sh/blog/ruff-v0.7.0) for a migration guide and overview of the changes!
Expand Down
Loading