Commit Graph

469 Commits

Author SHA1 Message Date
AreamanM daeb3ff37e fix cargo fmt warning 2023-03-09 15:49:09 -05:00
AreamanM 2f3734dd22 update test for plc1901 2023-03-09 15:49:09 -05:00
AreamanM fc50d28fcf cleanup impl for plc1901 2023-03-09 15:49:09 -05:00
AreamanM 158dc5e7d4 update `crate::ast::` to `ruff_python_ast::` 2023-03-09 15:49:09 -05:00
AreamanM 9a42be8a90 rough implementation of c1901 2023-03-09 15:49:09 -05:00
Charlie Marsh 024caca233
Introduce a `ruff_diagnostics` crate (#3409)
## Summary

This PR moves `Diagnostic`, `DiagnosticKind`, and `Fix` into their own crate, which will enable us to further split up Ruff, since sub-linter crates (which need to implement functions that return `Diagnostic`) can now depend on `ruff_diagnostics` rather than Ruff.
2023-03-09 20:48:57 +00:00
DanCardin 08ec11a31e
fix: Emit a more useful error if an `extend` points at a non-existent ruff.toml file. (#3417) 2023-03-09 19:55:09 +00:00
Micha Reiser bd05a8a74d
fix: WASM tests (#3415) 2023-03-09 11:27:59 +01:00
Micha Reiser 229f1c34cb
refactor: Extract `ruff_wasm` (#3401) 2023-03-09 10:07:39 +00:00
Charlie Marsh a7f3532395
Ignore multiply-assigned variables in RET504 (#3393) 2023-03-08 19:11:55 -05:00
Aaron Cunningham 3349ceb969
[`flake8-bugbear`] Add `flake8-bugbear`'s B030 rule (#3400) 2023-03-08 20:41:29 +00:00
Charlie Marsh da1f83fe32
Remove `core` module from `ruff_python_formatter` (#3373) 2023-03-08 19:11:39 +00:00
Charlie Marsh 0a9d259f9c
Remove copied `core` modules from `ruff_python_formatter` (#3371) 2023-03-08 19:03:40 +00:00
Charlie Marsh 130e733023
Implement `From<Located>` for `Range` (#3377) 2023-03-08 18:50:20 +00:00
Charlie Marsh ff2c0dd491
Use shared `leading_quote` implementation in ruff_python_formatter (#3396) 2023-03-08 18:21:59 +00:00
Charlie Marsh dfe1cad928
Rename `DiagnosticKind#commit` to `DiagnosticKind#suggestion` (#3397) 2023-03-08 18:06:19 +00:00
Charlie Marsh ffad0bcdaa
Decouple `Diagnostic` from "all violations" enumeration (#3352) 2023-03-08 17:51:37 +00:00
Jonathan Plasse bc869d4f52
Fix PIE802 broken auto-fix with trailing comma (#3402) 2023-03-08 12:49:01 -05:00
Micha Reiser a3de791f0a
Make `ruff_cli` binary a small wrapper around `lib` (#3398) 2023-03-08 12:11:55 +01:00
Charlie Marsh d9dfec30eb
Catch RET504 usages via decorators (#3395) 2023-03-08 00:38:01 +00:00
Charlie Marsh 3f04def3a5
Remap ChainMap, Counter, and OrderedDict imports to collections (#3392) 2023-03-07 23:53:35 +00:00
Charlie Marsh 98177754de
Handle multi-line fixes for byte-string prefixing (#3391) 2023-03-07 23:33:47 +00:00
Charlie Marsh bad6bdda1f
Create a `rust_python_ast` crate (#3370)
This PR productionizes @MichaReiser's suggestion in https://github.com/charliermarsh/ruff/issues/1820#issuecomment-1440204423, by creating a separate crate for the `ast` module (`rust_python_ast`). This will enable us to further split up the `ruff` crate, as we'll be able to create (e.g.) separate sub-linter crates that have access to these common AST utilities.

This was mostly a straightforward copy (with adjustments to module imports), as the few dependencies that _did_ require modifications were handled in #3366, #3367, and #3368.
2023-03-07 15:18:40 +00:00
Charlie Marsh a5d302fcbf
Pass `Range` struct by value (#3376) 2023-03-07 09:53:31 -05:00
Charlie Marsh bced58ce40
Rename `runtime-evaluated-baseclasses` to `runtime-evaluated-base-classes` (#3379) 2023-03-07 09:51:12 -05:00
Aaron Cunningham 10e252e2fb
Updated forced-separate type from Rust to abstract (#3380) 2023-03-07 09:35:39 -05:00
Sasan Jacob Rasti 4dead7541f
Implement configuration options `runtime-evaluated-decorators` and `runtime-evaluated-baseclasses` for `flake8-type-checking` (#3292) 2023-03-06 23:34:19 -05:00
Charlie Marsh fea1af5a63
Include entire prefix when reporting rule selector errors (#3375) 2023-03-07 00:04:52 +00:00
Charlie Marsh c0ad875339
Remove unnecessary quote-stripping method (#3372) 2023-03-06 18:28:20 -05:00
Charlie Marsh 8437399496
Remove AST checker's dependency on resolver (#3368) 2023-03-06 21:45:09 +00:00
StefanBRas 074f5634a5
Remove duplicate info in azure format (#3369) 2023-03-06 16:40:03 -05:00
Charlie Marsh 694d41897a
Move `visibility` module into `ast` crate (#3367) 2023-03-06 20:14:47 +00:00
Charlie Marsh e1ebd9130d
Don't enforce typing-import rules in .pyi files (#3362) 2023-03-06 15:03:34 -05:00
Charlie Marsh fc8ca6edd2
Remove source_code's dependency on pydocstyle (#3366) 2023-03-06 15:01:01 -05:00
konstin 709dba2e71
Remove old `define_violation!` (in favor of `#[violation]`) (#3310) 2023-03-06 17:00:29 +00:00
Charlie Marsh d1c48016eb
Rename `ruff_python` crate to `ruff_python_stdlib` (#3354)
In hindsight, `ruff_python` is too general. A good giveaway is that it's actually a prefix of some other crates. The intent of this crate is to reimplement pieces of the Python standard library and CPython itself, so `ruff_python_stdlib` feels appropriate.
2023-03-06 13:43:22 +00:00
konstin 348a38d261
Deprecate define violation (#3358)
* Add `#[violation]` proc macro as a replacement for `define_violation!`

* Switch all rules to #[violation]
2023-03-06 10:59:06 +00:00
konstin 22e6778e17
Add `cargo dev generate-all --check` and catch outdated docs in `cargo test` (#3320) 2023-03-06 11:28:38 +01:00
StefanBRas 30c71dc59a
Add Azure Devops as a `-format` option. (#3335) 2023-03-06 02:48:39 +00:00
Charlie Marsh 5d8591fec4
Skip byte-order-mark at start of file (#3343) 2023-03-05 21:37:14 -05:00
Carlos Gonçalves 673aa6e90f
feat(e231): add rule + autofix (#3344) 2023-03-05 20:09:35 +00:00
Charlie Marsh 51fe9f7d4b
Treat unary operations on constants as constant-like (#3348) 2023-03-04 16:30:33 -05:00
Charlie Marsh d7767b2bad
Use u8 to represent ambiguous representants (#3345) 2023-03-04 16:01:05 -05:00
Charlie Marsh 40d3b40c14
Move binding and scope tracking into a separate `ast::Context` struct (#3298) 2023-03-04 14:01:20 -05:00
Jonathan Plasse 8828e12283
Bump dependencies and move more shared dependencies into workspace (#3340) 2023-03-04 12:36:26 -05:00
Charlie Marsh f13633cc9f
Avoid panicking in invalid_escape_sequence (#3338) 2023-03-04 12:14:33 -05:00
Evan Rittenhouse 889c05c87e
Explicitly put `Path(...)` in Pathlib violations (#3333) 2023-03-04 04:33:12 +00:00
Charlie Marsh bbbc44336e
Bump version to 0.0.254 (#3331) 2023-03-03 19:11:07 -05:00
Charlie Marsh d216b2aaa8
Treat callables within type definitions as default-non-types (#3329) 2023-03-03 23:07:30 +00:00
Charlie Marsh 367cc43c42
Un-gate PEP 604 isinstance rewrites from keep_runtime_typing checks (#3328) 2023-03-03 17:29:41 -05:00