[ty] Merge ty_macros into ruff_macros (#19229)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks-instrumented (push) Blocked by required conditions
CI / benchmarks-walltime (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run

This commit is contained in:
Micha Reiser 2025-07-09 13:28:21 +02:00 committed by GitHub
parent f32f7a3b48
commit 35a33f045e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 22 additions and 62 deletions

11
Cargo.lock generated
View file

@ -4189,15 +4189,6 @@ dependencies = [
"ty_vendored", "ty_vendored",
] ]
[[package]]
name = "ty_macros"
version = "0.0.0"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "ty_project" name = "ty_project"
version = "0.0.0" version = "0.0.0"
@ -4316,7 +4307,7 @@ dependencies = [
name = "ty_static" name = "ty_static"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"ty_macros", "ruff_macros",
] ]
[[package]] [[package]]

View file

@ -41,7 +41,6 @@ ruff_workspace = { path = "crates/ruff_workspace" }
ty = { path = "crates/ty" } ty = { path = "crates/ty" }
ty_ide = { path = "crates/ty_ide" } ty_ide = { path = "crates/ty_ide" }
ty_macros = { path = "crates/ty_macros" }
ty_project = { path = "crates/ty_project", default-features = false } ty_project = { path = "crates/ty_project", default-features = false }
ty_python_semantic = { path = "crates/ty_python_semantic" } ty_python_semantic = { path = "crates/ty_python_semantic" }
ty_server = { path = "crates/ty_server" } ty_server = { path = "crates/ty_server" }
@ -85,7 +84,7 @@ get-size2 = { version = "0.5.0", features = [
"derive", "derive",
"smallvec", "smallvec",
"hashbrown", "hashbrown",
"compact-str" "compact-str",
] } ] }
glob = { version = "0.3.1" } glob = { version = "0.3.1" }
globset = { version = "0.4.14" } globset = { version = "0.4.14" }
@ -175,7 +174,7 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
"env-filter", "env-filter",
"fmt", "fmt",
"ansi", "ansi",
"smallvec" "smallvec",
] } ] }
tryfn = { version = "0.2.1" } tryfn = { version = "0.2.1" }
typed-arena = { version = "2.0.2" } typed-arena = { version = "2.0.2" }
@ -185,11 +184,7 @@ unicode-width = { version = "0.2.0" }
unicode_names2 = { version = "1.2.2" } unicode_names2 = { version = "1.2.2" }
unicode-normalization = { version = "0.1.23" } unicode-normalization = { version = "0.1.23" }
url = { version = "2.5.0" } url = { version = "2.5.0" }
uuid = { version = "1.6.1", features = [ uuid = { version = "1.6.1", features = ["v4", "fast-rng", "macro-diagnostics"] }
"v4",
"fast-rng",
"macro-diagnostics",
] }
walkdir = { version = "2.3.2" } walkdir = { version = "2.3.2" }
wasm-bindgen = { version = "0.2.92" } wasm-bindgen = { version = "0.2.92" }
wasm-bindgen-test = { version = "0.3.42" } wasm-bindgen-test = { version = "0.3.42" }
@ -224,8 +219,8 @@ must_use_candidate = "allow"
similar_names = "allow" similar_names = "allow"
single_match_else = "allow" single_match_else = "allow"
too_many_lines = "allow" too_many_lines = "allow"
needless_continue = "allow" # An explicit continue can be more readable, especially if the alternative is an empty block. needless_continue = "allow" # An explicit continue can be more readable, especially if the alternative is an empty block.
unnecessary_debug_formatting = "allow" # too many instances, the display also doesn't quote the path which is often desired in logs where we use them the most often. unnecessary_debug_formatting = "allow" # too many instances, the display also doesn't quote the path which is often desired in logs where we use them the most often.
# Without the hashes we run into a `rustfmt` bug in some snapshot tests, see #13250 # Without the hashes we run into a `rustfmt` bug in some snapshot tests, see #13250
needless_raw_string_hashes = "allow" needless_raw_string_hashes = "allow"
# Disallowed restriction lints # Disallowed restriction lints

View file

@ -1,4 +1,4 @@
//! This crate implements internal macros for the `ruff` library. //! This crate implements internal macros for the `ruff` and `ty` libraries.
use crate::cache_key::derive_cache_key; use crate::cache_key::derive_cache_key;
use crate::newtype_index::generate_newtype_index; use crate::newtype_index::generate_newtype_index;
@ -11,6 +11,7 @@ mod combine;
mod combine_options; mod combine_options;
mod config; mod config;
mod derive_message_formats; mod derive_message_formats;
mod env_vars;
mod kebab_case; mod kebab_case;
mod map_codes; mod map_codes;
mod newtype_index; mod newtype_index;
@ -144,3 +145,15 @@ pub fn newtype_index(_metadata: TokenStream, input: TokenStream) -> TokenStream
TokenStream::from(output) TokenStream::from(output)
} }
/// Generates metadata for environment variables declared in the impl block.
///
/// This attribute macro should be applied to an `impl EnvVars` block.
/// It will generate a `metadata()` method that returns all non-hidden
/// environment variables with their documentation.
#[proc_macro_attribute]
pub fn attribute_env_vars_metadata(_attr: TokenStream, item: TokenStream) -> TokenStream {
let input = parse_macro_input!(item as syn::ItemImpl);
env_vars::attribute_env_vars_metadata(input).into()
}

View file

@ -1,21 +0,0 @@
[package]
name = "ty_macros"
version = "0.0.0"
edition = { workspace = true }
rust-version = { workspace = true }
homepage = { workspace = true }
documentation = { workspace = true }
repository = { workspace = true }
authors = { workspace = true }
license = { workspace = true }
[lib]
proc-macro = true
[lints]
workspace = true
[dependencies]
proc-macro2 = { workspace = true }
quote = { workspace = true }
syn = { workspace = true }

View file

@ -1,18 +0,0 @@
//! This crate implements internal macros for the `ty` library.
use proc_macro::TokenStream;
use syn::parse_macro_input;
mod env_vars;
/// Generates metadata for environment variables declared in the impl block.
///
/// This attribute macro should be applied to an `impl EnvVars` block.
/// It will generate a `metadata()` method that returns all non-hidden
/// environment variables with their documentation.
#[proc_macro_attribute]
pub fn attribute_env_vars_metadata(_attr: TokenStream, item: TokenStream) -> TokenStream {
let input = parse_macro_input!(item as syn::ItemImpl);
env_vars::attribute_env_vars_metadata(input).into()
}

View file

@ -16,4 +16,4 @@ doctest = false
workspace = true workspace = true
[dependencies] [dependencies]
ty_macros = { workspace = true } ruff_macros = { workspace = true }

View file

@ -1,4 +1,4 @@
use ty_macros::attribute_env_vars_metadata; use ruff_macros::attribute_env_vars_metadata;
/// Declares all environment variable used throughout `ty` and its crates. /// Declares all environment variable used throughout `ty` and its crates.
pub struct EnvVars; pub struct EnvVars;