astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.

Home Page:https://docs.astral.sh/ruff

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

☂️ Remove dependencies of `Tok` from downstream tools

dhruvmanila opened this issue · comments

This issue is to keep track of all the tasks required to remove the Tok dependency from the downstream tools (linter and formatter).

Notes:

  • Certain tasks might need to be clubbed with the parser changes
  • The implementation logic for certain usages isn't finalized yet

Linter

  • Move these rules to the AST checker:
  • doc_lines_from_tokens (#11418)
  • Following rules can be updated to directly use TokenKind (via #11361):
  • remove_import_members uses lex method (#11511)
  • extract_noqa_line_for uses the kind information from the string token
  • locate_cmp_ops uses the lex method (#11562)
  • tokens_and_ranges extracts the comment ranges from the token stream
  • unsorted_dunder_all and unsorted_dunder_slots extracts the value from the string token (#11511)
  • UP032 uses the lex_starts_at method (#11511)
  • I001 (trailing_comma) uses the lex_starts_at method (#11511)
  • Stylist extracts the indentation and quote information from the token (#11592)
  • Indexer extracts trivia and string ranges, line continuation start value (#11592)

Formatter

  • Move away from lex_starts_at in write_suppressed_statements_starting_with_trailing_comment (#11515)

Internal document: https://www.notion.so/astral-sh/Downstream-work-items-551b86e104a34054b7192675550a6c25?pvs=4

Closed by #11628