Compare commits
1 Commits
dhruv/keep
...
dhruv/vers
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2db1c0fa96 |
130
.github/workflows/publish-docs.yml
vendored
130
.github/workflows/publish-docs.yml
vendored
@@ -36,28 +36,30 @@ jobs:
|
||||
version="${{ (inputs.plan != '' && fromJson(inputs.plan).announcement_tag) || inputs.ref }}"
|
||||
# if version is missing, exit with error
|
||||
if [[ -z "$version" ]]; then
|
||||
echo "Can't build docs without a version."
|
||||
exit 1
|
||||
echo "Can't build docs without a version."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use version as display name for now
|
||||
display_name="$version"
|
||||
|
||||
echo "version=$version" >> $GITHUB_ENV
|
||||
echo "display_name=$display_name" >> $GITHUB_ENV
|
||||
# Extract the major and minor part of the version for the docs
|
||||
docs_version="$(echo -n "$version" | cut -d "." -f 1-2)"
|
||||
|
||||
echo "version=$version" >> "$GITHUB_ENV"
|
||||
echo "docs_version=$docs_version" >> "$GITHUB_ENV"
|
||||
echo "display_name=$display_name" >> "$GITHUB_ENV"
|
||||
|
||||
- name: "Set branch name"
|
||||
run: |
|
||||
version="${{ env.version }}"
|
||||
display_name="${{ env.display_name }}"
|
||||
timestamp="$(date +%s)"
|
||||
|
||||
# create branch_display_name from display_name by replacing all
|
||||
# Create `branch_display_name` from `display_name` by replacing all
|
||||
# characters disallowed in git branch names with hyphens
|
||||
branch_display_name="$(echo "$display_name" | tr -c '[:alnum:]._' '-' | tr -s '-')"
|
||||
branch_display_name="$(echo -n "$display_name" | tr -c '[:alnum:]._' '-' | tr -s '-')"
|
||||
|
||||
echo "branch_name=update-docs-$branch_display_name-$timestamp" >> $GITHUB_ENV
|
||||
echo "timestamp=$timestamp" >> $GITHUB_ENV
|
||||
echo "branch_name=update-docs-$branch_display_name-$timestamp" >> "$GITHUB_ENV"
|
||||
echo "timestamp=$timestamp" >> "$GITHUB_ENV"
|
||||
|
||||
- name: "Add SSH key"
|
||||
if: ${{ env.MKDOCS_INSIDERS_SSH_KEY_EXISTS == 'true' }}
|
||||
@@ -70,7 +72,7 @@ jobs:
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: "Install Insiders dependencies"
|
||||
- name: "Install insiders dependencies"
|
||||
if: ${{ env.MKDOCS_INSIDERS_SSH_KEY_EXISTS == 'true' }}
|
||||
run: pip install -r docs/requirements-insiders.txt
|
||||
|
||||
@@ -78,74 +80,86 @@ jobs:
|
||||
if: ${{ env.MKDOCS_INSIDERS_SSH_KEY_EXISTS != 'true' }}
|
||||
run: pip install -r docs/requirements.txt
|
||||
|
||||
- name: "Copy README File"
|
||||
- name: "Fetch docs repo"
|
||||
run: |
|
||||
remote_name="astral-docs"
|
||||
|
||||
git remote add "$remote_name" https://${{ secrets.ASTRAL_DOCS_PAT }}@github.com/astral-sh/docs.git
|
||||
git fetch astral-docs "main:$branch_name"
|
||||
|
||||
echo "remote_name=$remote_name" >> "$GITHUB_ENV"
|
||||
|
||||
- name: "Configure git"
|
||||
run: |
|
||||
git config user.name "astral-docs-bot"
|
||||
git config user.email "176161322+astral-docs-bot@users.noreply.github.com"
|
||||
|
||||
- name: "Transform README and generate docs"
|
||||
run: |
|
||||
python scripts/transform_readme.py --target mkdocs
|
||||
python scripts/generate_mkdocs.py
|
||||
|
||||
- name: "Build Insiders docs"
|
||||
if: ${{ env.MKDOCS_INSIDERS_SSH_KEY_EXISTS == 'true' }}
|
||||
run: mkdocs build --strict -f mkdocs.insiders.yml
|
||||
run: |
|
||||
mike deploy \
|
||||
--remote "$remote_name" \
|
||||
--branch "$branch_name" \
|
||||
--message "Update ruff documentation for $version" \
|
||||
--config-file mkdocs.insiders.yml \
|
||||
--update-aliases \
|
||||
--push \
|
||||
"$docs_version" latest
|
||||
|
||||
- name: "Build docs"
|
||||
if: ${{ env.MKDOCS_INSIDERS_SSH_KEY_EXISTS != 'true' }}
|
||||
run: mkdocs build --strict -f mkdocs.public.yml
|
||||
|
||||
- name: "Clone docs repo"
|
||||
run: |
|
||||
version="${{ env.version }}"
|
||||
git clone https://${{ secrets.ASTRAL_DOCS_PAT }}@github.com/astral-sh/docs.git astral-docs
|
||||
|
||||
- name: "Copy docs"
|
||||
run: rm -rf astral-docs/site/ruff && mkdir -p astral-docs/site && cp -r site/ruff astral-docs/site/
|
||||
|
||||
- name: "Commit docs"
|
||||
working-directory: astral-docs
|
||||
run: |
|
||||
branch_name="${{ env.branch_name }}"
|
||||
|
||||
git config user.name "astral-docs-bot"
|
||||
git config user.email "176161322+astral-docs-bot@users.noreply.github.com"
|
||||
|
||||
git checkout -b $branch_name
|
||||
git add site/ruff
|
||||
git commit -m "Update ruff documentation for $version"
|
||||
mike deploy \
|
||||
--remote "$remote_name" \
|
||||
--branch "$branch_name" \
|
||||
--message "Update ruff documentation for $version" \
|
||||
--config-file mkdocs.public.yml \
|
||||
--update-aliases \
|
||||
--push \
|
||||
"$docs_version" latest
|
||||
|
||||
- name: "Create Pull Request"
|
||||
working-directory: astral-docs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ASTRAL_DOCS_PAT }}
|
||||
run: |
|
||||
version="${{ env.version }}"
|
||||
display_name="${{ env.display_name }}"
|
||||
branch_name="${{ env.branch_name }}"
|
||||
# Set the docs repository
|
||||
astral_docs_repo="astral-sh/docs"
|
||||
|
||||
# set the PR title
|
||||
# Set the PR title
|
||||
pull_request_title="Update ruff documentation for $display_name"
|
||||
|
||||
# Delete any existing pull requests that are open for this version
|
||||
# by checking against pull_request_title because the new PR will
|
||||
# by checking against `pull_request_title` because the new PR will
|
||||
# supersede the old one.
|
||||
gh pr list --state open --json title --jq '.[] | select(.title == "$pull_request_title") | .number' | \
|
||||
xargs -I {} gh pr close {}
|
||||
gh pr list \
|
||||
--state open \
|
||||
--json title,number \
|
||||
--jq '.[] | select(.title == "$pull_request_title") | .number' \
|
||||
--repo "$astral_docs_repo" | \
|
||||
xargs -I {} gh pr close {}
|
||||
|
||||
# push the branch to GitHub
|
||||
git push origin $branch_name
|
||||
|
||||
# create the PR
|
||||
gh pr create --base main --head $branch_name \
|
||||
# Create the PR, the branch has already been pushed by `mike`
|
||||
gh pr create --base main --head "$branch_name" \
|
||||
--title "$pull_request_title" \
|
||||
--body "Automated documentation update for $display_name" \
|
||||
--label "documentation"
|
||||
--label "documentation" \
|
||||
--repo "$astral_docs_repo"
|
||||
|
||||
- name: "Merge Pull Request"
|
||||
if: ${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
|
||||
working-directory: astral-docs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.ASTRAL_DOCS_PAT }}
|
||||
run: |
|
||||
branch_name="${{ env.branch_name }}"
|
||||
# auto-merge the PR if the build was triggered by a release. Manual builds should be reviewed by a human.
|
||||
# give the PR a few seconds to be created before trying to auto-merge it
|
||||
sleep 10
|
||||
gh pr merge --squash $branch_name
|
||||
# TODO(dhruvmanila): Uncomment once a patch and minor release are done, thus
|
||||
# confirming that it works as intended
|
||||
#
|
||||
# - name: "Merge Pull Request"
|
||||
# if: ${{ inputs.plan != '' && !fromJson(inputs.plan).announcement_tag_is_implicit }}
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.ASTRAL_DOCS_PAT }}
|
||||
# run: |
|
||||
# branch_name="${{ env.branch_name }}"
|
||||
# # auto-merge the PR if the build was triggered by a release. Manual builds should be reviewed by a human.
|
||||
# # give the PR a few seconds to be created before trying to auto-merge it
|
||||
# sleep 10
|
||||
# gh pr merge --squash $branch_name --repo "astral-sh/docs"
|
||||
|
||||
@@ -6,8 +6,6 @@ exclude: |
|
||||
crates/red_knot_workspace/resources/.*|
|
||||
crates/ruff_linter/resources/.*|
|
||||
crates/ruff_linter/src/rules/.*/snapshots/.*|
|
||||
crates/ruff_notebook/resources/.*|
|
||||
crates/ruff_server/resources/.*|
|
||||
crates/ruff/resources/.*|
|
||||
crates/ruff_python_formatter/resources/.*|
|
||||
crates/ruff_python_formatter/tests/snapshots/.*|
|
||||
@@ -17,7 +15,7 @@ exclude: |
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/abravalheri/validate-pyproject
|
||||
rev: v0.19
|
||||
rev: v0.18
|
||||
hooks:
|
||||
- id: validate-pyproject
|
||||
|
||||
@@ -59,7 +57,7 @@ repos:
|
||||
pass_filenames: false # This makes it a lot faster
|
||||
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.6.1
|
||||
rev: v0.5.7
|
||||
hooks:
|
||||
- id: ruff-format
|
||||
- id: ruff
|
||||
|
||||
@@ -2,6 +2,35 @@
|
||||
|
||||
Welcome! We're happy to have you here. Thank you in advance for your contribution to Ruff.
|
||||
|
||||
- [The Basics](#the-basics)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Development](#development)
|
||||
- [Project Structure](#project-structure)
|
||||
- [Example: Adding a new lint rule](#example-adding-a-new-lint-rule)
|
||||
- [Rule naming convention](#rule-naming-convention)
|
||||
- [Rule testing: fixtures and snapshots](#rule-testing-fixtures-and-snapshots)
|
||||
- [Example: Adding a new configuration option](#example-adding-a-new-configuration-option)
|
||||
- [MkDocs](#mkdocs)
|
||||
- [Release Process](#release-process)
|
||||
- [Creating a new release](#creating-a-new-release)
|
||||
- [Ecosystem CI](#ecosystem-ci)
|
||||
- [Benchmarking and Profiling](#benchmarking-and-profiling)
|
||||
- [CPython Benchmark](#cpython-benchmark)
|
||||
- [Microbenchmarks](#microbenchmarks)
|
||||
- [Benchmark-driven Development](#benchmark-driven-development)
|
||||
- [PR Summary](#pr-summary)
|
||||
- [Tips](#tips)
|
||||
- [Profiling Projects](#profiling-projects)
|
||||
- [Linux](#linux)
|
||||
- [Mac](#mac)
|
||||
- [`cargo dev`](#cargo-dev)
|
||||
- [Subsystems](#subsystems)
|
||||
- [Compilation Pipeline](#compilation-pipeline)
|
||||
- [Import Categorization](#import-categorization)
|
||||
- [Project root](#project-root)
|
||||
- [Package root](#package-root)
|
||||
- [Import categorization](#import-categorization-1)
|
||||
|
||||
## The Basics
|
||||
|
||||
Ruff welcomes contributions in the form of pull requests.
|
||||
@@ -304,34 +333,22 @@ even patch releases may contain [non-backwards-compatible changes](https://semve
|
||||
### Creating a new release
|
||||
|
||||
1. Install `uv`: `curl -LsSf https://astral.sh/uv/install.sh | sh`
|
||||
|
||||
1. Run `./scripts/release.sh`; this command will:
|
||||
|
||||
- Generate a temporary virtual environment with `rooster`
|
||||
- Generate a changelog entry in `CHANGELOG.md`
|
||||
- Update versions in `pyproject.toml` and `Cargo.toml`
|
||||
- Update references to versions in the `README.md` and documentation
|
||||
- Display contributors for the release
|
||||
|
||||
1. The changelog should then be editorialized for consistency
|
||||
|
||||
- Often labels will be missing from pull requests they will need to be manually organized into the proper section
|
||||
- Changes should be edited to be user-facing descriptions, avoiding internal details
|
||||
|
||||
1. Highlight any breaking changes in `BREAKING_CHANGES.md`
|
||||
|
||||
1. Run `cargo check`. This should update the lock file with new versions.
|
||||
|
||||
1. Create a pull request with the changelog and version updates
|
||||
|
||||
1. Merge the PR
|
||||
|
||||
1. Run the [release workflow](https://github.com/astral-sh/ruff/actions/workflows/release.yml) with:
|
||||
|
||||
- The new version number (without starting `v`)
|
||||
|
||||
1. The release workflow will do the following:
|
||||
|
||||
1. Build all the assets. If this fails (even though we tested in step 4), we haven't tagged or
|
||||
uploaded anything, you can restart after pushing a fix. If you just need to rerun the build,
|
||||
make sure you're [re-running all the failed
|
||||
@@ -342,25 +359,14 @@ even patch releases may contain [non-backwards-compatible changes](https://semve
|
||||
1. Attach artifacts to draft GitHub release
|
||||
1. Trigger downstream repositories. This can fail non-catastrophically, as we can run any
|
||||
downstream jobs manually if needed.
|
||||
|
||||
1. Verify the GitHub release:
|
||||
|
||||
1. The Changelog should match the content of `CHANGELOG.md`
|
||||
1. Append the contributors from the `scripts/release.sh` script
|
||||
|
||||
1. If needed, [update the schemastore](https://github.com/astral-sh/ruff/blob/main/scripts/update_schemastore.py).
|
||||
|
||||
1. One can determine if an update is needed when
|
||||
`git diff old-version-tag new-version-tag -- ruff.schema.json` returns a non-empty diff.
|
||||
1. Once run successfully, you should follow the link in the output to create a PR.
|
||||
|
||||
1. If needed, update the [`ruff-lsp`](https://github.com/astral-sh/ruff-lsp) and
|
||||
[`ruff-vscode`](https://github.com/astral-sh/ruff-vscode) repositories and follow
|
||||
the release instructions in those repositories. `ruff-lsp` should always be updated
|
||||
before `ruff-vscode`.
|
||||
|
||||
This step is generally not required for a patch release, but should always be done
|
||||
for a minor release.
|
||||
1. If needed, update the `ruff-lsp` and `ruff-vscode` repositories.
|
||||
|
||||
## Ecosystem CI
|
||||
|
||||
@@ -383,7 +389,7 @@ We have several ways of benchmarking and profiling Ruff:
|
||||
- Microbenchmarks which run the linter or the formatter on individual files. These run on pull requests.
|
||||
- Profiling the linter on either the microbenchmarks or entire projects
|
||||
|
||||
> **Note**
|
||||
> \[!NOTE\]
|
||||
> When running benchmarks, ensure that your CPU is otherwise idle (e.g., close any background
|
||||
> applications, like web browsers). You may also want to switch your CPU to a "performance"
|
||||
> mode, if it exists, especially when benchmarking short-lived processes.
|
||||
|
||||
@@ -463,25 +463,6 @@ mod tests {
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn augmented_assignment() {
|
||||
let TestCase { db, file } = test_case("x += 1");
|
||||
let scope = global_scope(&db, file);
|
||||
let global_table = symbol_table(&db, scope);
|
||||
|
||||
assert_eq!(names(&global_table), vec!["x"]);
|
||||
|
||||
let use_def = use_def_map(&db, scope);
|
||||
let definition = use_def
|
||||
.first_public_definition(global_table.symbol_id_by_name("x").unwrap())
|
||||
.unwrap();
|
||||
|
||||
assert!(matches!(
|
||||
definition.node(&db),
|
||||
DefinitionKind::AugmentedAssignment(_)
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn class_scope() {
|
||||
let TestCase { db, file } = test_case(
|
||||
@@ -1017,28 +998,4 @@ def x():
|
||||
vec!["bar", "foo", "Test", "<module>"]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_stmt_symbols() {
|
||||
let TestCase { db, file } = test_case(
|
||||
"
|
||||
match subject:
|
||||
case a: ...
|
||||
case [b, c, *d]: ...
|
||||
case e as f: ...
|
||||
case {'x': g, **h}: ...
|
||||
case Foo(i, z=j): ...
|
||||
case k | l: ...
|
||||
case _: ...
|
||||
",
|
||||
);
|
||||
|
||||
let global_table = symbol_table(&db, global_scope(&db, file));
|
||||
|
||||
assert!(global_table.symbol_by_name("Foo").unwrap().is_used());
|
||||
assert_eq!(
|
||||
names(&global_table),
|
||||
vec!["subject", "a", "b", "c", "d", "f", "e", "h", "g", "Foo", "i", "j", "k", "l"]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use ruff_db::parsed::ParsedModule;
|
||||
use ruff_index::IndexVec;
|
||||
use ruff_python_ast as ast;
|
||||
use ruff_python_ast::name::Name;
|
||||
use ruff_python_ast::visitor::{walk_expr, walk_pattern, walk_stmt, Visitor};
|
||||
use ruff_python_ast::visitor::{walk_expr, walk_stmt, Visitor};
|
||||
use ruff_python_ast::AnyParameterRef;
|
||||
|
||||
use crate::ast_node_ref::AstNodeRef;
|
||||
@@ -495,20 +495,6 @@ where
|
||||
self.visit_expr(&node.target);
|
||||
self.current_assignment = None;
|
||||
}
|
||||
ast::Stmt::AugAssign(
|
||||
aug_assign @ ast::StmtAugAssign {
|
||||
range: _,
|
||||
target,
|
||||
op: _,
|
||||
value,
|
||||
},
|
||||
) => {
|
||||
debug_assert!(self.current_assignment.is_none());
|
||||
self.visit_expr(value);
|
||||
self.current_assignment = Some(aug_assign.into());
|
||||
self.visit_expr(target);
|
||||
self.current_assignment = None;
|
||||
}
|
||||
ast::Stmt::If(node) => {
|
||||
self.visit_expr(&node.test);
|
||||
let pre_if = self.flow_snapshot();
|
||||
@@ -577,21 +563,12 @@ where
|
||||
|
||||
match expr {
|
||||
ast::Expr::Name(name_node @ ast::ExprName { id, ctx, .. }) => {
|
||||
let mut flags = match ctx {
|
||||
let flags = match ctx {
|
||||
ast::ExprContext::Load => SymbolFlags::IS_USED,
|
||||
ast::ExprContext::Store => SymbolFlags::IS_DEFINED,
|
||||
ast::ExprContext::Del => SymbolFlags::IS_DEFINED,
|
||||
ast::ExprContext::Invalid => SymbolFlags::empty(),
|
||||
};
|
||||
if matches!(
|
||||
self.current_assignment,
|
||||
Some(CurrentAssignment::AugAssign(_))
|
||||
) && !ctx.is_invalid()
|
||||
{
|
||||
// For augmented assignment, the target expression is also used, so we should
|
||||
// record that as a use.
|
||||
flags |= SymbolFlags::IS_USED;
|
||||
}
|
||||
let symbol = self.add_or_update_symbol(id.clone(), flags);
|
||||
if flags.contains(SymbolFlags::IS_DEFINED) {
|
||||
match self.current_assignment {
|
||||
@@ -607,9 +584,6 @@ where
|
||||
Some(CurrentAssignment::AnnAssign(ann_assign)) => {
|
||||
self.add_definition(symbol, ann_assign);
|
||||
}
|
||||
Some(CurrentAssignment::AugAssign(aug_assign)) => {
|
||||
self.add_definition(symbol, aug_assign);
|
||||
}
|
||||
Some(CurrentAssignment::Named(named)) => {
|
||||
// TODO(dhruvmanila): If the current scope is a comprehension, then the
|
||||
// named expression is implicitly nonlocal. This is yet to be
|
||||
@@ -747,32 +721,12 @@ where
|
||||
self.visit_parameter(parameter);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_pattern(&mut self, pattern: &'ast ast::Pattern) {
|
||||
if let ast::Pattern::MatchAs(ast::PatternMatchAs {
|
||||
name: Some(name), ..
|
||||
})
|
||||
| ast::Pattern::MatchStar(ast::PatternMatchStar {
|
||||
name: Some(name),
|
||||
range: _,
|
||||
})
|
||||
| ast::Pattern::MatchMapping(ast::PatternMatchMapping {
|
||||
rest: Some(name), ..
|
||||
}) = pattern
|
||||
{
|
||||
// TODO(dhruvmanila): Add definition
|
||||
self.add_or_update_symbol(name.id.clone(), SymbolFlags::IS_DEFINED);
|
||||
}
|
||||
|
||||
walk_pattern(self, pattern);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
enum CurrentAssignment<'a> {
|
||||
Assign(&'a ast::StmtAssign),
|
||||
AnnAssign(&'a ast::StmtAnnAssign),
|
||||
AugAssign(&'a ast::StmtAugAssign),
|
||||
Named(&'a ast::ExprNamed),
|
||||
Comprehension {
|
||||
node: &'a ast::Comprehension,
|
||||
@@ -792,12 +746,6 @@ impl<'a> From<&'a ast::StmtAnnAssign> for CurrentAssignment<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ast::StmtAugAssign> for CurrentAssignment<'a> {
|
||||
fn from(value: &'a ast::StmtAugAssign) -> Self {
|
||||
Self::AugAssign(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ast::ExprNamed> for CurrentAssignment<'a> {
|
||||
fn from(value: &'a ast::ExprNamed) -> Self {
|
||||
Self::Named(value)
|
||||
|
||||
@@ -44,7 +44,6 @@ pub(crate) enum DefinitionNodeRef<'a> {
|
||||
NamedExpression(&'a ast::ExprNamed),
|
||||
Assignment(AssignmentDefinitionNodeRef<'a>),
|
||||
AnnotatedAssignment(&'a ast::StmtAnnAssign),
|
||||
AugmentedAssignment(&'a ast::StmtAugAssign),
|
||||
Comprehension(ComprehensionDefinitionNodeRef<'a>),
|
||||
Parameter(ast::AnyParameterRef<'a>),
|
||||
}
|
||||
@@ -73,12 +72,6 @@ impl<'a> From<&'a ast::StmtAnnAssign> for DefinitionNodeRef<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ast::StmtAugAssign> for DefinitionNodeRef<'a> {
|
||||
fn from(node: &'a ast::StmtAugAssign) -> Self {
|
||||
Self::AugmentedAssignment(node)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ast::Alias> for DefinitionNodeRef<'a> {
|
||||
fn from(node_ref: &'a ast::Alias) -> Self {
|
||||
Self::Import(node_ref)
|
||||
@@ -158,9 +151,6 @@ impl DefinitionNodeRef<'_> {
|
||||
DefinitionNodeRef::AnnotatedAssignment(assign) => {
|
||||
DefinitionKind::AnnotatedAssignment(AstNodeRef::new(parsed, assign))
|
||||
}
|
||||
DefinitionNodeRef::AugmentedAssignment(augmented_assignment) => {
|
||||
DefinitionKind::AugmentedAssignment(AstNodeRef::new(parsed, augmented_assignment))
|
||||
}
|
||||
DefinitionNodeRef::Comprehension(ComprehensionDefinitionNodeRef { node, first }) => {
|
||||
DefinitionKind::Comprehension(ComprehensionDefinitionKind {
|
||||
node: AstNodeRef::new(parsed, node),
|
||||
@@ -192,7 +182,6 @@ impl DefinitionNodeRef<'_> {
|
||||
target,
|
||||
}) => target.into(),
|
||||
Self::AnnotatedAssignment(node) => node.into(),
|
||||
Self::AugmentedAssignment(node) => node.into(),
|
||||
Self::Comprehension(ComprehensionDefinitionNodeRef { node, first: _ }) => node.into(),
|
||||
Self::Parameter(node) => match node {
|
||||
ast::AnyParameterRef::Variadic(parameter) => parameter.into(),
|
||||
@@ -211,7 +200,6 @@ pub enum DefinitionKind {
|
||||
NamedExpression(AstNodeRef<ast::ExprNamed>),
|
||||
Assignment(AssignmentDefinitionKind),
|
||||
AnnotatedAssignment(AstNodeRef<ast::StmtAnnAssign>),
|
||||
AugmentedAssignment(AstNodeRef<ast::StmtAugAssign>),
|
||||
Comprehension(ComprehensionDefinitionKind),
|
||||
Parameter(AstNodeRef<ast::Parameter>),
|
||||
ParameterWithDefault(AstNodeRef<ast::ParameterWithDefault>),
|
||||
@@ -305,12 +293,6 @@ impl From<&ast::StmtAnnAssign> for DefinitionNodeKey {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&ast::StmtAugAssign> for DefinitionNodeKey {
|
||||
fn from(node: &ast::StmtAugAssign) -> Self {
|
||||
Self(NodeKey::from_node(node))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&ast::Comprehension> for DefinitionNodeKey {
|
||||
fn from(node: &ast::Comprehension) -> Self {
|
||||
Self(NodeKey::from_node(node))
|
||||
|
||||
@@ -303,9 +303,6 @@ impl<'db> TypeInferenceBuilder<'db> {
|
||||
DefinitionKind::AnnotatedAssignment(annotated_assignment) => {
|
||||
self.infer_annotated_assignment_definition(annotated_assignment.node(), definition);
|
||||
}
|
||||
DefinitionKind::AugmentedAssignment(augmented_assignment) => {
|
||||
self.infer_augment_assignment_definition(augmented_assignment.node(), definition);
|
||||
}
|
||||
DefinitionKind::NamedExpression(named_expression) => {
|
||||
self.infer_named_expression_definition(named_expression.node(), definition);
|
||||
}
|
||||
@@ -766,35 +763,15 @@ impl<'db> TypeInferenceBuilder<'db> {
|
||||
}
|
||||
|
||||
fn infer_augmented_assignment_statement(&mut self, assignment: &ast::StmtAugAssign) {
|
||||
if assignment.target.is_name_expr() {
|
||||
self.infer_definition(assignment);
|
||||
} else {
|
||||
// TODO currently we don't consider assignments to non-Names to be Definitions
|
||||
self.infer_augment_assignment(assignment);
|
||||
}
|
||||
}
|
||||
|
||||
fn infer_augment_assignment_definition(
|
||||
&mut self,
|
||||
assignment: &ast::StmtAugAssign,
|
||||
definition: Definition<'db>,
|
||||
) {
|
||||
let target_ty = self.infer_augment_assignment(assignment);
|
||||
self.types.definitions.insert(definition, target_ty);
|
||||
}
|
||||
|
||||
fn infer_augment_assignment(&mut self, assignment: &ast::StmtAugAssign) -> Type<'db> {
|
||||
// TODO this should be a Definition
|
||||
let ast::StmtAugAssign {
|
||||
range: _,
|
||||
target,
|
||||
op: _,
|
||||
value,
|
||||
} = assignment;
|
||||
self.infer_expression(value);
|
||||
self.infer_expression(target);
|
||||
|
||||
// TODO(dhruvmanila): Resolve the target type using the value type and the operator
|
||||
Type::Unknown
|
||||
self.infer_expression(value);
|
||||
}
|
||||
|
||||
fn infer_type_alias_statement(&mut self, type_alias_statement: &ast::StmtTypeAlias) {
|
||||
|
||||
@@ -28,7 +28,6 @@ thiserror = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
ruff_db = { workspace = true, features = ["testing"]}
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
import decimal
|
||||
|
||||
# Tests with fully qualified import
|
||||
decimal.Decimal(0)
|
||||
|
||||
decimal.Decimal(0.0) # Should error
|
||||
|
||||
decimal.Decimal("0.0")
|
||||
|
||||
decimal.Decimal(10)
|
||||
|
||||
decimal.Decimal(10.0) # Should error
|
||||
|
||||
decimal.Decimal("10.0")
|
||||
|
||||
decimal.Decimal(-10)
|
||||
|
||||
decimal.Decimal(-10.0) # Should error
|
||||
|
||||
decimal.Decimal("-10.0")
|
||||
|
||||
a = 10.0
|
||||
|
||||
decimal.Decimal(a)
|
||||
|
||||
|
||||
# Tests with relative import
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
val = Decimal(0)
|
||||
|
||||
val = Decimal(0.0) # Should error
|
||||
|
||||
val = Decimal("0.0")
|
||||
|
||||
val = Decimal(10)
|
||||
|
||||
val = Decimal(10.0) # Should error
|
||||
|
||||
val = Decimal("10.0")
|
||||
|
||||
val = Decimal(-10)
|
||||
|
||||
val = Decimal(-10.0) # Should error
|
||||
|
||||
val = Decimal("-10.0")
|
||||
|
||||
a = 10.0
|
||||
|
||||
val = Decimal(a)
|
||||
|
||||
|
||||
# Tests with shadowed name
|
||||
class Decimal():
|
||||
value: float | int | str
|
||||
|
||||
def __init__(self, value: float | int | str) -> None:
|
||||
self.value = value
|
||||
|
||||
|
||||
val = Decimal(0.0)
|
||||
|
||||
val = Decimal("0.0")
|
||||
|
||||
val = Decimal(10.0)
|
||||
|
||||
val = Decimal("10.0")
|
||||
|
||||
val = Decimal(-10.0)
|
||||
|
||||
val = Decimal("-10.0")
|
||||
|
||||
a = 10.0
|
||||
|
||||
val = Decimal(a)
|
||||
|
||||
|
||||
# Retest with fully qualified import
|
||||
|
||||
val = decimal.Decimal(0.0) # Should error
|
||||
|
||||
val = decimal.Decimal("0.0")
|
||||
|
||||
val = decimal.Decimal(10.0) # Should error
|
||||
|
||||
val = decimal.Decimal("10.0")
|
||||
|
||||
val = decimal.Decimal(-10.0) # Should error
|
||||
|
||||
val = decimal.Decimal("-10.0")
|
||||
|
||||
a = 10.0
|
||||
|
||||
val = decimal.Decimal(a)
|
||||
|
||||
|
||||
class decimal():
|
||||
class Decimal():
|
||||
value: float | int | str
|
||||
|
||||
def __init__(self, value: float | int | str) -> None:
|
||||
self.value = value
|
||||
|
||||
|
||||
val = decimal.Decimal(0.0)
|
||||
|
||||
val = decimal.Decimal("0.0")
|
||||
|
||||
val = decimal.Decimal(10.0)
|
||||
|
||||
val = decimal.Decimal("10.0")
|
||||
|
||||
val = decimal.Decimal(-10.0)
|
||||
|
||||
val = decimal.Decimal("-10.0")
|
||||
|
||||
a = 10.0
|
||||
|
||||
val = decimal.Decimal(a)
|
||||
@@ -1011,9 +1011,6 @@ pub(crate) fn expression(expr: &Expr, checker: &mut Checker) {
|
||||
if checker.enabled(Rule::UnnecessaryIterableAllocationForFirstElement) {
|
||||
ruff::rules::unnecessary_iterable_allocation_for_first_element(checker, expr);
|
||||
}
|
||||
if checker.enabled(Rule::DecimalFromFloatLiteral) {
|
||||
ruff::rules::decimal_from_float_literal_syntax(checker, call);
|
||||
}
|
||||
if checker.enabled(Rule::IntOnSlicedStr) {
|
||||
refurb::rules::int_on_sliced_str(checker, call);
|
||||
}
|
||||
|
||||
@@ -959,7 +959,6 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
||||
(Ruff, "029") => (RuleGroup::Preview, rules::ruff::rules::UnusedAsync),
|
||||
(Ruff, "030") => (RuleGroup::Preview, rules::ruff::rules::AssertWithPrintMessage),
|
||||
(Ruff, "031") => (RuleGroup::Preview, rules::ruff::rules::IncorrectlyParenthesizedTupleInSubscript),
|
||||
(Ruff, "032") => (RuleGroup::Preview, rules::ruff::rules::DecimalFromFloatLiteral),
|
||||
(Ruff, "100") => (RuleGroup::Stable, rules::ruff::rules::UnusedNOQA),
|
||||
(Ruff, "101") => (RuleGroup::Stable, rules::ruff::rules::RedirectedNOQA),
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ pub(crate) fn typing_only_runtime_import(
|
||||
// Categorize the import, using coarse-grained categorization.
|
||||
let import_type = match categorize(
|
||||
&qualified_name.to_string(),
|
||||
qualified_name.is_unresolved_import(),
|
||||
0,
|
||||
&checker.settings.src,
|
||||
checker.package(),
|
||||
checker.settings.isort.detect_same_package,
|
||||
|
||||
@@ -91,7 +91,7 @@ enum Reason<'a> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn categorize<'a>(
|
||||
module_name: &str,
|
||||
is_relative: bool,
|
||||
level: u32,
|
||||
src: &[PathBuf],
|
||||
package: Option<&Path>,
|
||||
detect_same_package: bool,
|
||||
@@ -103,14 +103,14 @@ pub(crate) fn categorize<'a>(
|
||||
) -> &'a ImportSection {
|
||||
let module_base = module_name.split('.').next().unwrap();
|
||||
let (mut import_type, mut reason) = {
|
||||
if !is_relative && module_base == "__future__" {
|
||||
if level == 0 && module_base == "__future__" {
|
||||
(&ImportSection::Known(ImportType::Future), Reason::Future)
|
||||
} else if no_sections {
|
||||
(
|
||||
&ImportSection::Known(ImportType::FirstParty),
|
||||
Reason::NoSections,
|
||||
)
|
||||
} else if is_relative {
|
||||
} else if level > 0 {
|
||||
(
|
||||
&ImportSection::Known(ImportType::LocalFolder),
|
||||
Reason::NonZeroLevel,
|
||||
@@ -132,7 +132,7 @@ pub(crate) fn categorize<'a>(
|
||||
&ImportSection::Known(ImportType::FirstParty),
|
||||
Reason::SourceMatch(src),
|
||||
)
|
||||
} else if !is_relative && module_name == "__main__" {
|
||||
} else if level == 0 && module_name == "__main__" {
|
||||
(
|
||||
&ImportSection::Known(ImportType::FirstParty),
|
||||
Reason::KnownFirstParty,
|
||||
@@ -190,7 +190,7 @@ pub(crate) fn categorize_imports<'a>(
|
||||
for (alias, comments) in block.import {
|
||||
let import_type = categorize(
|
||||
&alias.module_name(),
|
||||
false,
|
||||
0,
|
||||
src,
|
||||
package,
|
||||
detect_same_package,
|
||||
@@ -210,7 +210,7 @@ pub(crate) fn categorize_imports<'a>(
|
||||
for (import_from, aliases) in block.import_from {
|
||||
let classification = categorize(
|
||||
&import_from.module_name(),
|
||||
import_from.level > 0,
|
||||
import_from.level,
|
||||
src,
|
||||
package,
|
||||
detect_same_package,
|
||||
@@ -230,7 +230,7 @@ pub(crate) fn categorize_imports<'a>(
|
||||
for ((import_from, alias), aliases) in block.import_from_as {
|
||||
let classification = categorize(
|
||||
&import_from.module_name(),
|
||||
import_from.level > 0,
|
||||
import_from.level,
|
||||
src,
|
||||
package,
|
||||
detect_same_package,
|
||||
@@ -250,7 +250,7 @@ pub(crate) fn categorize_imports<'a>(
|
||||
for (import_from, comments) in block.import_from_star {
|
||||
let classification = categorize(
|
||||
&import_from.module_name(),
|
||||
import_from.level > 0,
|
||||
import_from.level,
|
||||
src,
|
||||
package,
|
||||
detect_same_package,
|
||||
|
||||
@@ -6,7 +6,8 @@ use std::collections::BTreeMap;
|
||||
|
||||
use ruff_diagnostics::{Applicability, Diagnostic, Fix, FixAvailability, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::{self as ast, Stmt};
|
||||
use ruff_python_ast as ast;
|
||||
use ruff_python_ast::{Stmt, StmtImportFrom};
|
||||
use ruff_python_semantic::{
|
||||
AnyImport, BindingKind, Exceptions, Imported, NodeId, Scope, SemanticModel, SubmoduleImport,
|
||||
};
|
||||
@@ -217,11 +218,10 @@ enum UnusedImportContext {
|
||||
Other,
|
||||
}
|
||||
|
||||
fn is_first_party(import: &AnyImport, checker: &Checker) -> bool {
|
||||
let qualified_name = import.qualified_name();
|
||||
fn is_first_party(qualified_name: &str, level: u32, checker: &Checker) -> bool {
|
||||
let category = isort::categorize(
|
||||
&qualified_name.to_string(),
|
||||
qualified_name.is_unresolved_import(),
|
||||
qualified_name,
|
||||
level,
|
||||
&checker.settings.src,
|
||||
checker.package(),
|
||||
checker.settings.isort.detect_same_package,
|
||||
@@ -343,6 +343,13 @@ pub(crate) fn unused_import(checker: &Checker, scope: &Scope, diagnostics: &mut
|
||||
let in_except_handler =
|
||||
exceptions.intersects(Exceptions::MODULE_NOT_FOUND_ERROR | Exceptions::IMPORT_ERROR);
|
||||
let multiple = bindings.len() > 1;
|
||||
let level = match checker.semantic().statement(import_statement) {
|
||||
Stmt::Import(_) => 0,
|
||||
Stmt::ImportFrom(StmtImportFrom { level, .. }) => *level,
|
||||
_ => {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
// pair each binding with context; divide them by how we want to fix them
|
||||
let (to_reexport, to_remove): (Vec<_>, Vec<_>) = bindings
|
||||
@@ -350,7 +357,9 @@ pub(crate) fn unused_import(checker: &Checker, scope: &Scope, diagnostics: &mut
|
||||
.map(|binding| {
|
||||
let context = if in_except_handler {
|
||||
UnusedImportContext::ExceptHandler
|
||||
} else if in_init && is_first_party(&binding.import, checker) {
|
||||
} else if in_init
|
||||
&& is_first_party(&binding.import.qualified_name().to_string(), level, checker)
|
||||
{
|
||||
UnusedImportContext::DunderInitFirstParty {
|
||||
dunder_all_count: DunderAllCount::from(dunder_all_exprs.len()),
|
||||
submodule_import: binding.import.is_submodule_import(),
|
||||
|
||||
@@ -57,7 +57,6 @@ mod tests {
|
||||
#[test_case(Rule::UnusedAsync, Path::new("RUF029.py"))]
|
||||
#[test_case(Rule::AssertWithPrintMessage, Path::new("RUF030.py"))]
|
||||
#[test_case(Rule::IncorrectlyParenthesizedTupleInSubscript, Path::new("RUF031.py"))]
|
||||
#[test_case(Rule::DecimalFromFloatLiteral, Path::new("RUF032.py"))]
|
||||
#[test_case(Rule::RedirectedNOQA, Path::new("RUF101.py"))]
|
||||
fn rules(rule_code: Rule, path: &Path) -> Result<()> {
|
||||
let snapshot = format!("{}_{}", rule_code.noqa_code(), path.to_string_lossy());
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
use ruff_diagnostics::{AlwaysFixableViolation, Diagnostic, Edit, Fix};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
use ruff_python_ast::{self as ast};
|
||||
use ruff_python_codegen::Stylist;
|
||||
use ruff_text_size::{Ranged, TextRange};
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for `Decimal` calls passing a float literal.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// Float literals have limited precision that can lead to unexpected results.
|
||||
/// The `Decimal` class is designed to handle numbers with fixed-point precision,
|
||||
/// so a string literal should be used instead.
|
||||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```python
|
||||
/// num = Decimal(1.2345)
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
/// ```python
|
||||
/// num = Decimal("1.2345")
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix Safety
|
||||
/// This rule's fix is marked as unsafe because it changes the underlying value
|
||||
/// of the `Decimal` instance that is constructed. This can lead to unexpected
|
||||
/// behavior if your program relies on the previous value (whether deliberately or not).
|
||||
#[violation]
|
||||
pub struct DecimalFromFloatLiteral;
|
||||
|
||||
impl AlwaysFixableViolation for DecimalFromFloatLiteral {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
format!("`Decimal()` called with float literal argument")
|
||||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
"Use a string literal instead".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// RUF032: `Decimal()` called with float literal argument
|
||||
pub(crate) fn decimal_from_float_literal_syntax(checker: &mut Checker, call: &ast::ExprCall) {
|
||||
let Some(arg) = call.arguments.args.first() else {
|
||||
return;
|
||||
};
|
||||
|
||||
if !is_arg_float_literal(arg) {
|
||||
return;
|
||||
}
|
||||
|
||||
if checker
|
||||
.semantic()
|
||||
.resolve_qualified_name(call.func.as_ref())
|
||||
.is_some_and(|qualified_name| matches!(qualified_name.segments(), ["decimal", "Decimal"]))
|
||||
{
|
||||
let diagnostic =
|
||||
Diagnostic::new(DecimalFromFloatLiteral, arg.range()).with_fix(fix_float_literal(
|
||||
arg.range(),
|
||||
&checker.generator().expr(arg),
|
||||
checker.stylist(),
|
||||
));
|
||||
checker.diagnostics.push(diagnostic);
|
||||
}
|
||||
}
|
||||
|
||||
fn is_arg_float_literal(arg: &ast::Expr) -> bool {
|
||||
match arg {
|
||||
ast::Expr::NumberLiteral(ast::ExprNumberLiteral {
|
||||
value: ast::Number::Float(_),
|
||||
..
|
||||
}) => true,
|
||||
ast::Expr::UnaryOp(ast::ExprUnaryOp { operand, .. }) => is_arg_float_literal(operand),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn fix_float_literal(range: TextRange, float_literal: &str, stylist: &Stylist) -> Fix {
|
||||
let content = format!("{quote}{float_literal}{quote}", quote = stylist.quote());
|
||||
Fix::unsafe_edit(Edit::range_replacement(content, range))
|
||||
}
|
||||
@@ -3,7 +3,6 @@ pub(crate) use assert_with_print_message::*;
|
||||
pub(crate) use assignment_in_assert::*;
|
||||
pub(crate) use asyncio_dangling_task::*;
|
||||
pub(crate) use collection_literal_concatenation::*;
|
||||
pub(crate) use decimal_from_float_literal::*;
|
||||
pub(crate) use default_factory_kwarg::*;
|
||||
pub(crate) use explicit_f_string_type_conversion::*;
|
||||
pub(crate) use function_call_in_dataclass_default::*;
|
||||
@@ -37,7 +36,6 @@ mod assignment_in_assert;
|
||||
mod asyncio_dangling_task;
|
||||
mod collection_literal_concatenation;
|
||||
mod confusables;
|
||||
mod decimal_from_float_literal;
|
||||
mod default_factory_kwarg;
|
||||
mod explicit_f_string_type_conversion;
|
||||
mod function_call_in_dataclass_default;
|
||||
|
||||
@@ -1,191 +0,0 @@
|
||||
---
|
||||
source: crates/ruff_linter/src/rules/ruff/mod.rs
|
||||
---
|
||||
RUF032.py:6:17: RUF032 [*] `Decimal()` called with float literal argument
|
||||
|
|
||||
4 | decimal.Decimal(0)
|
||||
5 |
|
||||
6 | decimal.Decimal(0.0) # Should error
|
||||
| ^^^ RUF032
|
||||
7 |
|
||||
8 | decimal.Decimal("0.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
|
||||
ℹ Unsafe fix
|
||||
3 3 | # Tests with fully qualified import
|
||||
4 4 | decimal.Decimal(0)
|
||||
5 5 |
|
||||
6 |-decimal.Decimal(0.0) # Should error
|
||||
6 |+decimal.Decimal("0.0") # Should error
|
||||
7 7 |
|
||||
8 8 | decimal.Decimal("0.0")
|
||||
9 9 |
|
||||
|
||||
RUF032.py:12:17: RUF032 [*] `Decimal()` called with float literal argument
|
||||
|
|
||||
10 | decimal.Decimal(10)
|
||||
11 |
|
||||
12 | decimal.Decimal(10.0) # Should error
|
||||
| ^^^^ RUF032
|
||||
13 |
|
||||
14 | decimal.Decimal("10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
|
||||
ℹ Unsafe fix
|
||||
9 9 |
|
||||
10 10 | decimal.Decimal(10)
|
||||
11 11 |
|
||||
12 |-decimal.Decimal(10.0) # Should error
|
||||
12 |+decimal.Decimal("10.0") # Should error
|
||||
13 13 |
|
||||
14 14 | decimal.Decimal("10.0")
|
||||
15 15 |
|
||||
|
||||
RUF032.py:18:17: RUF032 [*] `Decimal()` called with float literal argument
|
||||
|
|
||||
16 | decimal.Decimal(-10)
|
||||
17 |
|
||||
18 | decimal.Decimal(-10.0) # Should error
|
||||
| ^^^^^ RUF032
|
||||
19 |
|
||||
20 | decimal.Decimal("-10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
|
||||
ℹ Unsafe fix
|
||||
15 15 |
|
||||
16 16 | decimal.Decimal(-10)
|
||||
17 17 |
|
||||
18 |-decimal.Decimal(-10.0) # Should error
|
||||
18 |+decimal.Decimal("-10.0") # Should error
|
||||
19 19 |
|
||||
20 20 | decimal.Decimal("-10.0")
|
||||
21 21 |
|
||||
|
||||
RUF032.py:33:15: RUF032 [*] `Decimal()` called with float literal argument
|
||||
|
|
||||
31 | val = Decimal(0)
|
||||
32 |
|
||||
33 | val = Decimal(0.0) # Should error
|
||||
| ^^^ RUF032
|
||||
34 |
|
||||
35 | val = Decimal("0.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
|
||||
ℹ Unsafe fix
|
||||
30 30 |
|
||||
31 31 | val = Decimal(0)
|
||||
32 32 |
|
||||
33 |-val = Decimal(0.0) # Should error
|
||||
33 |+val = Decimal("0.0") # Should error
|
||||
34 34 |
|
||||
35 35 | val = Decimal("0.0")
|
||||
36 36 |
|
||||
|
||||
RUF032.py:39:15: RUF032 [*] `Decimal()` called with float literal argument
|
||||
|
|
||||
37 | val = Decimal(10)
|
||||
38 |
|
||||
39 | val = Decimal(10.0) # Should error
|
||||
| ^^^^ RUF032
|
||||
40 |
|
||||
41 | val = Decimal("10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
|
||||
ℹ Unsafe fix
|
||||
36 36 |
|
||||
37 37 | val = Decimal(10)
|
||||
38 38 |
|
||||
39 |-val = Decimal(10.0) # Should error
|
||||
39 |+val = Decimal("10.0") # Should error
|
||||
40 40 |
|
||||
41 41 | val = Decimal("10.0")
|
||||
42 42 |
|
||||
|
||||
RUF032.py:45:15: RUF032 [*] `Decimal()` called with float literal argument
|
||||
|
|
||||
43 | val = Decimal(-10)
|
||||
44 |
|
||||
45 | val = Decimal(-10.0) # Should error
|
||||
| ^^^^^ RUF032
|
||||
46 |
|
||||
47 | val = Decimal("-10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
|
||||
ℹ Unsafe fix
|
||||
42 42 |
|
||||
43 43 | val = Decimal(-10)
|
||||
44 44 |
|
||||
45 |-val = Decimal(-10.0) # Should error
|
||||
45 |+val = Decimal("-10.0") # Should error
|
||||
46 46 |
|
||||
47 47 | val = Decimal("-10.0")
|
||||
48 48 |
|
||||
|
||||
RUF032.py:81:23: RUF032 [*] `Decimal()` called with float literal argument
|
||||
|
|
||||
79 | # Retest with fully qualified import
|
||||
80 |
|
||||
81 | val = decimal.Decimal(0.0) # Should error
|
||||
| ^^^ RUF032
|
||||
82 |
|
||||
83 | val = decimal.Decimal("0.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
|
||||
ℹ Unsafe fix
|
||||
78 78 |
|
||||
79 79 | # Retest with fully qualified import
|
||||
80 80 |
|
||||
81 |-val = decimal.Decimal(0.0) # Should error
|
||||
81 |+val = decimal.Decimal("0.0") # Should error
|
||||
82 82 |
|
||||
83 83 | val = decimal.Decimal("0.0")
|
||||
84 84 |
|
||||
|
||||
RUF032.py:85:23: RUF032 [*] `Decimal()` called with float literal argument
|
||||
|
|
||||
83 | val = decimal.Decimal("0.0")
|
||||
84 |
|
||||
85 | val = decimal.Decimal(10.0) # Should error
|
||||
| ^^^^ RUF032
|
||||
86 |
|
||||
87 | val = decimal.Decimal("10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
|
||||
ℹ Unsafe fix
|
||||
82 82 |
|
||||
83 83 | val = decimal.Decimal("0.0")
|
||||
84 84 |
|
||||
85 |-val = decimal.Decimal(10.0) # Should error
|
||||
85 |+val = decimal.Decimal("10.0") # Should error
|
||||
86 86 |
|
||||
87 87 | val = decimal.Decimal("10.0")
|
||||
88 88 |
|
||||
|
||||
RUF032.py:89:23: RUF032 [*] `Decimal()` called with float literal argument
|
||||
|
|
||||
87 | val = decimal.Decimal("10.0")
|
||||
88 |
|
||||
89 | val = decimal.Decimal(-10.0) # Should error
|
||||
| ^^^^^ RUF032
|
||||
90 |
|
||||
91 | val = decimal.Decimal("-10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
|
||||
ℹ Unsafe fix
|
||||
86 86 |
|
||||
87 87 | val = decimal.Decimal("10.0")
|
||||
88 88 |
|
||||
89 |-val = decimal.Decimal(-10.0) # Should error
|
||||
89 |+val = decimal.Decimal("-10.0") # Should error
|
||||
90 90 |
|
||||
91 91 | val = decimal.Decimal("-10.0")
|
||||
92 92 |
|
||||
@@ -47,7 +47,7 @@ pub struct Options {
|
||||
/// This setting will override even the `RUFF_CACHE_DIR` environment
|
||||
/// variable, if set.
|
||||
#[option(
|
||||
default = r#"".ruff_cache""#,
|
||||
default = ".ruff_cache",
|
||||
value_type = "str",
|
||||
example = r#"cache-dir = "~/.cache/ruff""#
|
||||
)]
|
||||
@@ -553,7 +553,7 @@ pub struct LintCommonOptions {
|
||||
/// default expression matches `_`, `__`, and `_var`, but not `_var_`.
|
||||
#[option(
|
||||
default = r#""^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$""#,
|
||||
value_type = "str",
|
||||
value_type = "re.Pattern",
|
||||
example = r#"
|
||||
# Only ignore variables named "_".
|
||||
dummy-variable-rgx = "^_$"
|
||||
@@ -1171,7 +1171,7 @@ pub struct Flake8CopyrightOptions {
|
||||
/// - `Copyright (C) 2021-2023`
|
||||
/// - `Copyright (C) 2021, 2023`
|
||||
#[option(
|
||||
default = r#""(?i)Copyright\s+((?:\(C\)|©)\s+)?\d{4}((-|,\s)\d{4})*""#,
|
||||
default = r#"(?i)Copyright\s+((?:\(C\)|©)\s+)?\d{4}((-|,\s)\d{4})*"#,
|
||||
value_type = "str",
|
||||
example = r#"notice-rgx = "(?i)Copyright \\(C\\) \\d{4}""#
|
||||
)]
|
||||
@@ -2029,7 +2029,7 @@ pub struct IsortOptions {
|
||||
/// this to "closest-to-furthest" is equivalent to isort's
|
||||
/// `reverse-relative = true`.
|
||||
#[option(
|
||||
default = r#""furthest-to-closest""#,
|
||||
default = r#"furthest-to-closest"#,
|
||||
value_type = r#""furthest-to-closest" | "closest-to-furthest""#,
|
||||
example = r#"
|
||||
relative-imports-order = "closest-to-furthest"
|
||||
@@ -2146,7 +2146,7 @@ pub struct IsortOptions {
|
||||
|
||||
/// Define a default section for any imports that don't fit into the specified [`section-order`](#lint_isort_section-order).
|
||||
#[option(
|
||||
default = r#""third-party""#,
|
||||
default = r#"third-party"#,
|
||||
value_type = "str",
|
||||
example = r#"
|
||||
default-section = "first-party"
|
||||
@@ -2660,8 +2660,8 @@ pub struct PycodestyleOptions {
|
||||
pub max_doc_length: Option<LineLength>,
|
||||
|
||||
/// Whether line-length violations (`E501`) should be triggered for
|
||||
/// comments starting with [`task-tags`](#lint_task-tags) (by default: "TODO", "FIXME",
|
||||
/// and "XXX").
|
||||
/// comments starting with [`task-tags`](#lint_task-tags) (by default: \["TODO", "FIXME",
|
||||
/// and "XXX"\]).
|
||||
#[option(
|
||||
default = "false",
|
||||
value_type = "bool",
|
||||
@@ -3059,7 +3059,7 @@ pub struct FormatOptions {
|
||||
///
|
||||
/// See [`indent-width`](#indent-width) to configure the number of spaces per indentation and the tab width.
|
||||
#[option(
|
||||
default = r#""space""#,
|
||||
default = "space",
|
||||
value_type = r#""space" | "tab""#,
|
||||
example = r#"
|
||||
# Use tabs instead of 4 space indentation.
|
||||
@@ -3092,7 +3092,7 @@ pub struct FormatOptions {
|
||||
/// a mixture of single and double quotes and can't migrate to the `double` or `single` style.
|
||||
/// The quote style `preserve` leaves the quotes of all strings unchanged.
|
||||
#[option(
|
||||
default = r#""double""#,
|
||||
default = r#"double"#,
|
||||
value_type = r#""double" | "single" | "preserve""#,
|
||||
example = r#"
|
||||
# Prefer single quotes over double quotes.
|
||||
@@ -3136,7 +3136,7 @@ pub struct FormatOptions {
|
||||
/// * `cr-lf`: Line endings will be converted to `\r\n`. The default line ending on Windows.
|
||||
/// * `native`: Line endings will be converted to `\n` on Unix and `\r\n` on Windows.
|
||||
#[option(
|
||||
default = r#""auto""#,
|
||||
default = r#"auto"#,
|
||||
value_type = r#""auto" | "lf" | "cr-lf" | "native""#,
|
||||
example = r#"
|
||||
# Use `\n` line endings for all files
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
-r requirements.txt
|
||||
PyYAML==6.0.2
|
||||
black==24.8.0
|
||||
mkdocs==1.6.0
|
||||
mkdocs-material @ git+ssh://git@github.com/astral-sh/mkdocs-material-insiders.git@38c0b8187325c3bab386b666daf3518ac036f2f4
|
||||
mkdocs-redirects==1.2.1
|
||||
mdformat==0.7.17
|
||||
mdformat-mkdocs==3.0.0
|
||||
mdformat-admon==2.0.6
|
||||
|
||||
@@ -61,6 +61,9 @@ markdown_extensions:
|
||||
plugins:
|
||||
- search
|
||||
- typeset
|
||||
- mike:
|
||||
deploy_prefix: site/ruff
|
||||
canonical_version: latest
|
||||
extra_css:
|
||||
- stylesheets/extra.css
|
||||
extra_javascript:
|
||||
@@ -71,8 +74,6 @@ not_in_nav: |
|
||||
extra:
|
||||
analytics:
|
||||
provider: fathom
|
||||
validation:
|
||||
omitted_files: warn
|
||||
absolute_links: warn
|
||||
unrecognized_links: warn
|
||||
anchors: warn
|
||||
version:
|
||||
provider: mike
|
||||
alias: true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"plugins": ["@typescript-eslint", "prettier"],
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
@@ -9,7 +9,8 @@
|
||||
"plugin:react/jsx-runtime",
|
||||
"plugin:react-hooks/recommended",
|
||||
"plugin:import/recommended",
|
||||
"plugin:import/typescript"
|
||||
"plugin:import/typescript",
|
||||
"plugin:prettier/recommended"
|
||||
],
|
||||
"rules": {
|
||||
// Disable some recommended rules that we don't want to enforce.
|
||||
|
||||
36
playground/api/package-lock.json
generated
36
playground/api/package-lock.json
generated
@@ -16,7 +16,7 @@
|
||||
"@cloudflare/workers-types": "^4.20230801.0",
|
||||
"miniflare": "^3.20230801.1",
|
||||
"typescript": "^5.1.6",
|
||||
"wrangler": "3.72.0"
|
||||
"wrangler": "3.70.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@cloudflare/kv-asset-handler": {
|
||||
@@ -118,19 +118,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@cloudflare/workers-shared": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@cloudflare/workers-shared/-/workers-shared-0.2.0.tgz",
|
||||
"integrity": "sha512-tIWLooWkBMuoKRk72lr6YrEtVlVdUTtAGVmPOnUroMrnri/9YLx+mVawL0/egDgSGmPbmvkdBFsUGRuI+aZmxg==",
|
||||
"dev": true,
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=16.7.0"
|
||||
}
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@cloudflare/workers-shared/-/workers-shared-0.1.0.tgz",
|
||||
"integrity": "sha512-SyD4iw6jM4anZaG+ujgVETV4fulF2KHBOW31eavbVN7TNpk2l4aJgwY1YSPK00IKSWsoQuH2TigR446KuT5lqQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@cloudflare/workers-types": {
|
||||
"version": "4.20240815.0",
|
||||
"resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-4.20240815.0.tgz",
|
||||
"integrity": "sha512-H/IXCOahT1lr4RKzsiCkyjM7+LCPLtl2wjxyLG8xMTNERR0XuD1Vcfns6TraE0cd5+IcKe7j3rpzBlSCjZ+61A==",
|
||||
"version": "4.20240806.0",
|
||||
"resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-4.20240806.0.tgz",
|
||||
"integrity": "sha512-8lvgrwXGTZEBsUQJ8YUnMk72Anh9omwr6fqWLw/EwVgcw1nQxs/bfdadBEbdP48l9fWXjE4E5XERLUrrFuEpsg==",
|
||||
"dev": true,
|
||||
"license": "MIT OR Apache-2.0"
|
||||
},
|
||||
@@ -1115,9 +1111,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/miniflare": {
|
||||
"version": "3.20240806.1",
|
||||
"resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20240806.1.tgz",
|
||||
"integrity": "sha512-wJq3YQYx9k83L2CNYtxvwWvXSi+uHrC6aFoXYSbzhxIDlUWvMEqippj+3HeKLgsggC31nHJab3b1Pifg9IxIFQ==",
|
||||
"version": "3.20240806.0",
|
||||
"resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20240806.0.tgz",
|
||||
"integrity": "sha512-jDsXBJOLUVpIQXHsluX3xV0piDxXolTCsxdje2Ex2LTC9PsSoBIkMwvCmnCxe9wpJJCq8rb0UMyeEn3KOF3LOw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -1603,21 +1599,21 @@
|
||||
}
|
||||
},
|
||||
"node_modules/wrangler": {
|
||||
"version": "3.72.0",
|
||||
"resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.72.0.tgz",
|
||||
"integrity": "sha512-9sryHTCtCj48vUC5y/M3Dsx02U1bT6mK9E41TXBCpSJgWh8UvWG/xgmu2dY93Mqj9aJIvK/kwwIBRlNFRwF7Hw==",
|
||||
"version": "3.70.0",
|
||||
"resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.70.0.tgz",
|
||||
"integrity": "sha512-aMtCEXmH02SIxbxOFGGuJ8ZemmG9W+IcNRh5D4qIKgzSxqy0mt9mRoPNPSv1geGB2/8YAyeLGPf+tB4lxz+ssg==",
|
||||
"dev": true,
|
||||
"license": "MIT OR Apache-2.0",
|
||||
"dependencies": {
|
||||
"@cloudflare/kv-asset-handler": "0.3.4",
|
||||
"@cloudflare/workers-shared": "0.2.0",
|
||||
"@cloudflare/workers-shared": "0.1.0",
|
||||
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
|
||||
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
|
||||
"blake3-wasm": "^2.1.5",
|
||||
"chokidar": "^3.5.3",
|
||||
"date-fns": "^3.6.0",
|
||||
"esbuild": "0.17.19",
|
||||
"miniflare": "3.20240806.1",
|
||||
"miniflare": "3.20240806.0",
|
||||
"nanoid": "^3.3.3",
|
||||
"path-to-regexp": "^6.2.0",
|
||||
"resolve": "^1.22.8",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"@cloudflare/workers-types": "^4.20230801.0",
|
||||
"miniflare": "^3.20230801.1",
|
||||
"typescript": "^5.1.6",
|
||||
"wrangler": "3.72.0"
|
||||
"wrangler": "3.70.0"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
189
playground/package-lock.json
generated
189
playground/package-lock.json
generated
@@ -26,6 +26,7 @@
|
||||
"eslint": "^8.30.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"eslint-plugin-react": "^7.31.11",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"postcss": "^8.4.20",
|
||||
@@ -649,6 +650,18 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@pkgr/core": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz",
|
||||
"integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/unts"
|
||||
}
|
||||
},
|
||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||
"version": "4.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.13.0.tgz",
|
||||
@@ -1083,17 +1096,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.1.0.tgz",
|
||||
"integrity": "sha512-LlNBaHFCEBPHyD4pZXb35mzjGkuGKXU5eeCA1SxvHfiRES0E82dOounfVpL4DCqYvJEKab0bZIA0gCRpdLKkCw==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.0.1.tgz",
|
||||
"integrity": "sha512-5g3Y7GDFsJAnY4Yhvk8sZtFfV6YNF2caLzjrRPUBzewjPCaj0yokePB4LJSobyCzGMzjZZYFbwuzbfDHlimXbQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.10.0",
|
||||
"@typescript-eslint/scope-manager": "8.1.0",
|
||||
"@typescript-eslint/type-utils": "8.1.0",
|
||||
"@typescript-eslint/utils": "8.1.0",
|
||||
"@typescript-eslint/visitor-keys": "8.1.0",
|
||||
"@typescript-eslint/scope-manager": "8.0.1",
|
||||
"@typescript-eslint/type-utils": "8.0.1",
|
||||
"@typescript-eslint/utils": "8.0.1",
|
||||
"@typescript-eslint/visitor-keys": "8.0.1",
|
||||
"graphemer": "^1.4.0",
|
||||
"ignore": "^5.3.1",
|
||||
"natural-compare": "^1.4.0",
|
||||
@@ -1117,16 +1130,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.1.0.tgz",
|
||||
"integrity": "sha512-U7iTAtGgJk6DPX9wIWPPOlt1gO57097G06gIcl0N0EEnNw8RGD62c+2/DiP/zL7KrkqnnqF7gtFGR7YgzPllTA==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.0.1.tgz",
|
||||
"integrity": "sha512-5IgYJ9EO/12pOUwiBKFkpU7rS3IU21mtXzB81TNwq2xEybcmAZrE9qwDtsb5uQd9aVO9o0fdabFyAmKveXyujg==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.1.0",
|
||||
"@typescript-eslint/types": "8.1.0",
|
||||
"@typescript-eslint/typescript-estree": "8.1.0",
|
||||
"@typescript-eslint/visitor-keys": "8.1.0",
|
||||
"@typescript-eslint/scope-manager": "8.0.1",
|
||||
"@typescript-eslint/types": "8.0.1",
|
||||
"@typescript-eslint/typescript-estree": "8.0.1",
|
||||
"@typescript-eslint/visitor-keys": "8.0.1",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
@@ -1146,14 +1159,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.1.0.tgz",
|
||||
"integrity": "sha512-DsuOZQji687sQUjm4N6c9xABJa7fjvfIdjqpSIIVOgaENf2jFXiM9hIBZOL3hb6DHK9Nvd2d7zZnoMLf9e0OtQ==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.0.1.tgz",
|
||||
"integrity": "sha512-NpixInP5dm7uukMiRyiHjRKkom5RIFA4dfiHvalanD2cF0CLUuQqxfg8PtEUo9yqJI2bBhF+pcSafqnG3UBnRQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.1.0",
|
||||
"@typescript-eslint/visitor-keys": "8.1.0"
|
||||
"@typescript-eslint/types": "8.0.1",
|
||||
"@typescript-eslint/visitor-keys": "8.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -1164,14 +1177,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.1.0.tgz",
|
||||
"integrity": "sha512-oLYvTxljVvsMnldfl6jIKxTaU7ok7km0KDrwOt1RHYu6nxlhN3TIx8k5Q52L6wR33nOwDgM7VwW1fT1qMNfFIA==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.0.1.tgz",
|
||||
"integrity": "sha512-+/UT25MWvXeDX9YaHv1IS6KI1fiuTto43WprE7pgSMswHbn1Jm9GEM4Txp+X74ifOWV8emu2AWcbLhpJAvD5Ng==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/typescript-estree": "8.1.0",
|
||||
"@typescript-eslint/utils": "8.1.0",
|
||||
"@typescript-eslint/typescript-estree": "8.0.1",
|
||||
"@typescript-eslint/utils": "8.0.1",
|
||||
"debug": "^4.3.4",
|
||||
"ts-api-utils": "^1.3.0"
|
||||
},
|
||||
@@ -1189,9 +1202,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.1.0.tgz",
|
||||
"integrity": "sha512-q2/Bxa0gMOu/2/AKALI0tCKbG2zppccnRIRCW6BaaTlRVaPKft4oVYPp7WOPpcnsgbr0qROAVCVKCvIQ0tbWog==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.0.1.tgz",
|
||||
"integrity": "sha512-PpqTVT3yCA/bIgJ12czBuE3iBlM3g4inRSC5J0QOdQFAn07TYrYEQBBKgXH1lQpglup+Zy6c1fxuwTk4MTNKIw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -1203,14 +1216,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.1.0.tgz",
|
||||
"integrity": "sha512-NTHhmufocEkMiAord/g++gWKb0Fr34e9AExBRdqgWdVBaKoei2dIyYKD9Q0jBnvfbEA5zaf8plUFMUH6kQ0vGg==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.0.1.tgz",
|
||||
"integrity": "sha512-8V9hriRvZQXPWU3bbiUV4Epo7EvgM6RTs+sUmxp5G//dBGy402S7Fx0W0QkB2fb4obCF8SInoUzvTYtc3bkb5w==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.1.0",
|
||||
"@typescript-eslint/visitor-keys": "8.1.0",
|
||||
"@typescript-eslint/types": "8.0.1",
|
||||
"@typescript-eslint/visitor-keys": "8.0.1",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
@@ -1258,16 +1271,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.1.0.tgz",
|
||||
"integrity": "sha512-ypRueFNKTIFwqPeJBfeIpxZ895PQhNyH4YID6js0UoBImWYoSjBsahUn9KMiJXh94uOjVBgHD9AmkyPsPnFwJA==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.0.1.tgz",
|
||||
"integrity": "sha512-CBFR0G0sCt0+fzfnKaciu9IBsKvEKYwN9UZ+eeogK1fYHg4Qxk1yf/wLQkLXlq8wbU2dFlgAesxt8Gi76E8RTA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.4.0",
|
||||
"@typescript-eslint/scope-manager": "8.1.0",
|
||||
"@typescript-eslint/types": "8.1.0",
|
||||
"@typescript-eslint/typescript-estree": "8.1.0"
|
||||
"@typescript-eslint/scope-manager": "8.0.1",
|
||||
"@typescript-eslint/types": "8.0.1",
|
||||
"@typescript-eslint/typescript-estree": "8.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -1281,13 +1294,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.1.0.tgz",
|
||||
"integrity": "sha512-ba0lNI19awqZ5ZNKh6wCModMwoZs457StTebQ0q1NP58zSi2F6MOZRXwfKZy+jB78JNJ/WH8GSh2IQNzXX8Nag==",
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.0.1.tgz",
|
||||
"integrity": "sha512-W5E+o0UfUcK5EgchLZsyVWqARmsM7v54/qEq6PY3YI5arkgmCzHiuk0zKSJJbm71V0xdRna4BGomkCTXz2/LkQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.1.0",
|
||||
"@typescript-eslint/types": "8.0.1",
|
||||
"eslint-visitor-keys": "^3.4.3"
|
||||
},
|
||||
"engines": {
|
||||
@@ -2440,6 +2453,37 @@
|
||||
"semver": "bin/semver.js"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-prettier": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz",
|
||||
"integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prettier-linter-helpers": "^1.0.0",
|
||||
"synckit": "^0.9.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint-plugin-prettier"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/eslint": ">=8.0.0",
|
||||
"eslint": ">=8.0.0",
|
||||
"eslint-config-prettier": "*",
|
||||
"prettier": ">=3.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/eslint": {
|
||||
"optional": true
|
||||
},
|
||||
"eslint-config-prettier": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-react": {
|
||||
"version": "7.35.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.35.0.tgz",
|
||||
@@ -2619,6 +2663,12 @@
|
||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/fast-diff": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz",
|
||||
"integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/fast-glob": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.0.tgz",
|
||||
@@ -4165,6 +4215,18 @@
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/prettier-linter-helpers": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
|
||||
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"fast-diff": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prop-types": {
|
||||
"version": "15.8.1",
|
||||
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
||||
@@ -4235,9 +4297,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/react-resizable-panels": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/react-resizable-panels/-/react-resizable-panels-2.1.0.tgz",
|
||||
"integrity": "sha512-k2gGjGyCNF9xq8gVkkHBK1mlWv6xetPtvRdEtD914gTdhJcy02TLF0xMPuVLlGRuLoWGv7Gd/O1rea2KIQb3Qw==",
|
||||
"version": "2.0.23",
|
||||
"resolved": "https://registry.npmjs.org/react-resizable-panels/-/react-resizable-panels-2.0.23.tgz",
|
||||
"integrity": "sha512-8ZKTwTU11t/FYwiwhMdtZYYyFxic5U5ysRu2YwfkAgDbUJXFvnWSJqhnzkSlW+mnDoNAzDCrJhdOSXBPA76wug==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "^16.14.0 || ^17.0.0 || ^18.0.0",
|
||||
@@ -4746,10 +4808,27 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/synckit": {
|
||||
"version": "0.9.1",
|
||||
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.1.tgz",
|
||||
"integrity": "sha512-7gr8p9TQP6RAHusBOSLs46F4564ZrjV8xFmw5zCmgmhGUcw2hxsShhJ6CEiHQMgPDwAQ1fWHPM0ypc4RMAig4A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pkgr/core": "^0.1.0",
|
||||
"tslib": "^2.6.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/unts"
|
||||
}
|
||||
},
|
||||
"node_modules/tailwindcss": {
|
||||
"version": "3.4.10",
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.10.tgz",
|
||||
"integrity": "sha512-KWZkVPm7yJRhdu4SRSl9d4AK2wM3a50UsvgHZO7xY77NQr2V+fIrEuoDGQcbvswWvFGbS2f6e+jC/6WJm1Dl0w==",
|
||||
"version": "3.4.9",
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.9.tgz",
|
||||
"integrity": "sha512-1SEOvRr6sSdV5IDf9iC+NU4dhwdqzF4zKKq3sAbasUWHEM6lsMhX+eNN5gkPx1BvLFEnZQEUFbXnGj8Qlp83Pg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -4853,6 +4932,12 @@
|
||||
"strip-bom": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
|
||||
@@ -5026,14 +5111,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "5.4.1",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.1.tgz",
|
||||
"integrity": "sha512-1oE6yuNXssjrZdblI9AfBbHCC41nnyoVoEZxQnID6yvQZAFBzxxkqoFLtHUMkYunL8hwOLEjgTuxpkRxvba3kA==",
|
||||
"version": "5.4.0",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.0.tgz",
|
||||
"integrity": "sha512-5xokfMX0PIiwCMCMb9ZJcMyh5wbBun0zUzKib+L65vAZ8GY9ePZMXxFrHbr/Kyll2+LSCY7xtERPpxkBDKngwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.21.3",
|
||||
"postcss": "^8.4.41",
|
||||
"postcss": "^8.4.40",
|
||||
"rollup": "^4.13.0"
|
||||
},
|
||||
"bin": {
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"eslint": "^8.30.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"eslint-plugin-react": "^7.31.11",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"postcss": "^8.4.20",
|
||||
|
||||
@@ -3,7 +3,7 @@ import Header from "./Header";
|
||||
import { persist, persistLocal, restore, stringify } from "./settings";
|
||||
import { useTheme } from "./theme";
|
||||
import { default as Editor, Source } from "./Editor";
|
||||
import initRuff, { Workspace } from "../pkg";
|
||||
import initRuff, { Workspace } from "../pkg/ruff_wasm";
|
||||
import { loader } from "@monaco-editor/react";
|
||||
import { setupMonaco } from "./setupMonaco";
|
||||
import { DEFAULT_PYTHON_SOURCE } from "../constants";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useDeferredValue, useMemo, useState } from "react";
|
||||
import { Panel, PanelGroup } from "react-resizable-panels";
|
||||
import { Diagnostic, Workspace } from "../pkg";
|
||||
import { Diagnostic, Workspace } from "../pkg/ruff_wasm";
|
||||
import { ErrorMessage } from "./ErrorMessage";
|
||||
import PrimarySideBar from "./PrimarySideBar";
|
||||
import { HorizontalResizeHandle } from "./ResizeHandle";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import Editor, { BeforeMount, Monaco } from "@monaco-editor/react";
|
||||
import { MarkerSeverity, MarkerTag } from "monaco-editor";
|
||||
import { useCallback, useEffect, useRef } from "react";
|
||||
import { Diagnostic } from "../pkg";
|
||||
import { Diagnostic } from "../pkg/ruff_wasm";
|
||||
import { Theme } from "./theme";
|
||||
|
||||
export default function SourceEditor({
|
||||
@@ -83,10 +83,7 @@ export default function SourceEditor({
|
||||
}
|
||||
: undefined,
|
||||
}));
|
||||
return {
|
||||
actions,
|
||||
dispose: () => {},
|
||||
};
|
||||
return { actions, dispose: () => {} };
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
3
ruff.schema.json
generated
3
ruff.schema.json
generated
@@ -2430,7 +2430,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ignore-overlong-task-comments": {
|
||||
"description": "Whether line-length violations (`E501`) should be triggered for comments starting with [`task-tags`](#lint_task-tags) (by default: \"TODO\", \"FIXME\", and \"XXX\").",
|
||||
"description": "Whether line-length violations (`E501`) should be triggered for comments starting with [`task-tags`](#lint_task-tags) (by default: \\[\"TODO\", \"FIXME\", and \"XXX\"\\]).",
|
||||
"type": [
|
||||
"boolean",
|
||||
"null"
|
||||
@@ -3738,7 +3738,6 @@
|
||||
"RUF03",
|
||||
"RUF030",
|
||||
"RUF031",
|
||||
"RUF032",
|
||||
"RUF1",
|
||||
"RUF10",
|
||||
"RUF100",
|
||||
|
||||
Reference in New Issue
Block a user