Skip to content

Commit 310a834

Browse files
committed
cspell derive
1 parent 0b6546a commit 310a834

File tree

14 files changed

+98
-71
lines changed

14 files changed

+98
-71
lines changed

.cspell.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,23 @@
3232
"cstring",
3333
"flate2",
3434
"hasher",
35+
"idents",
3536
"indexmap",
3637
"insta",
3738
"keccak",
3839
"lalrpop",
40+
"libc",
3941
"Manually",
42+
"maplit",
4043
"memmap",
44+
"metas",
4145
"peekable",
4246
"prepended",
47+
"punct",
4348
"rustc",
4449
"rustfmt",
4550
"splitn",
51+
"trai",
4652
"unic",
4753
"unistd",
4854
// Python
@@ -52,6 +58,7 @@
5258
"basicsize",
5359
"cformat",
5460
"classcell",
61+
"codepoint",
5562
"cpython",
5663
"defaultaction",
5764
"descr",
@@ -68,10 +75,13 @@
6875
"fstrings",
6976
"genexpr",
7077
"getattro",
78+
"getformat",
79+
"getnewargs",
7180
"getweakrefcount",
7281
"getweakrefs",
7382
"idiv",
7483
"impls",
84+
"instancecheck",
7585
"instanceof",
7686
"itemsize",
7787
"iternext",
@@ -103,6 +113,7 @@
103113
"setcomp",
104114
"stacklevel",
105115
"subclasscheck",
116+
"subclasshook",
106117
"unionable",
107118
"unraisablehook",
108119
"vararg",
@@ -113,15 +124,20 @@
113124
"weakproxy",
114125
"xopts",
115126
// RustPython
127+
"baseclass",
116128
"Bytecode",
129+
"cfgs",
117130
"codegen",
118131
"dedentations",
119132
"dedents",
120133
"deduped",
134+
"downcasted",
121135
"dumpable",
122136
"GetSet",
137+
"internable",
123138
"makeunicodedata",
124139
"miri",
140+
"notrace",
125141
"pyarg",
126142
"pyarg",
127143
"pyargs",
@@ -133,18 +149,25 @@
133149
"PyFunction",
134150
"pygetset",
135151
"pyimpl",
152+
"pymember",
136153
"PyMethod",
137154
"PyModule",
155+
"pyname",
138156
"pyobj",
139157
"PyObject",
158+
"pypayload",
140159
"PyProperty",
141160
"pyref",
142161
"PyResult",
143162
"pyslot",
144163
"PyStaticMethod",
145164
"pystr",
165+
"pystruct",
166+
"pystructseq",
167+
"pytrace",
146168
"richcompare",
147169
"RustPython",
170+
"struc",
148171
"tracebacks",
149172
"typealiases",
150173
"Unconstructible",
@@ -158,6 +181,8 @@
158181
"asdl",
159182
"asname",
160183
"augassign",
184+
"badsyntax",
185+
"basetype",
161186
"boolop",
162187
"bxor",
163188
"cellarg",
@@ -190,7 +215,8 @@
190215
"unparser",
191216
"VARKEYWORDS",
192217
"varkwarg",
193-
"withitem"
218+
"withitem",
219+
"withs"
194220
],
195221
// flagWords - list of words to be always considered incorrect
196222
"flagWords": [

derive-impl/src/compile_bytecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static CARGO_MANIFEST_DIR: Lazy<PathBuf> = Lazy::new(|| {
3838
enum CompilationSourceKind {
3939
/// Source is a File (Path)
4040
File(PathBuf),
41-
/// Direct Raw sourcecode
41+
/// Direct Raw source code
4242
SourceCode(String),
4343
/// Source is a directory
4444
Dir(PathBuf),

derive-impl/src/from_args.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl ArgAttribute {
8686
self.default = Some(None);
8787
}
8888
} else {
89-
bail_span!(path, "Unrecognised pyarg attribute");
89+
bail_span!(path, "Unrecognized pyarg attribute");
9090
}
9191
}
9292
NestedMeta::Meta(Meta::NameValue(name_value)) => {
@@ -109,10 +109,10 @@ impl ArgAttribute {
109109
_ => bail_span!(name_value, "Expected string value for name argument"),
110110
}
111111
} else {
112-
bail_span!(name_value, "Unrecognised pyarg attribute");
112+
bail_span!(name_value, "Unrecognized pyarg attribute");
113113
}
114114
}
115-
_ => bail_span!(arg, "Unrecognised pyarg attribute"),
115+
_ => bail_span!(arg, "Unrecognized pyarg attribute"),
116116
}
117117

118118
Ok(())
@@ -138,24 +138,24 @@ fn generate_field((i, field): (usize, &Field)) -> Result<TokenStream> {
138138
};
139139

140140
let name = field.ident.as_ref();
141-
let namestring = name.map(Ident::to_string);
142-
if matches!(&namestring, Some(s) if s.starts_with("_phantom")) {
141+
let name_string = name.map(Ident::to_string);
142+
if matches!(&name_string, Some(s) if s.starts_with("_phantom")) {
143143
return Ok(quote! {
144144
#name: ::std::marker::PhantomData,
145145
});
146146
}
147-
let fieldname = match name {
147+
let field_name = match name {
148148
Some(id) => id.to_token_stream(),
149149
None => syn::Index::from(i).into_token_stream(),
150150
};
151151
if let ParameterKind::Flatten = attr.kind {
152152
return Ok(quote! {
153-
#fieldname: ::rustpython_vm::function::FromArgs::from_args(vm, args)?,
153+
#field_name: ::rustpython_vm::function::FromArgs::from_args(vm, args)?,
154154
});
155155
}
156156
let pyname = attr
157157
.name
158-
.or(namestring)
158+
.or(name_string)
159159
.ok_or_else(|| err_span!(field, "field in tuple struct must have name attribute"))?;
160160
let middle = quote! {
161161
.map(|x| ::rustpython_vm::convert::TryFromObject::try_from_object(vm, x)).transpose()?
@@ -184,17 +184,17 @@ fn generate_field((i, field): (usize, &Field)) -> Result<TokenStream> {
184184
let file_output = match attr.kind {
185185
ParameterKind::PositionalOnly => {
186186
quote! {
187-
#fieldname: args.take_positional()#middle #ending,
187+
#field_name: args.take_positional()#middle #ending,
188188
}
189189
}
190190
ParameterKind::PositionalOrKeyword => {
191191
quote! {
192-
#fieldname: args.take_positional_keyword(#pyname)#middle #ending,
192+
#field_name: args.take_positional_keyword(#pyname)#middle #ending,
193193
}
194194
}
195195
ParameterKind::KeywordOnly => {
196196
quote! {
197-
#fieldname: args.take_keyword(#pyname)#middle #ending,
197+
#field_name: args.take_keyword(#pyname)#middle #ending,
198198
}
199199
}
200200
ParameterKind::Flatten => unreachable!(),

derive-impl/src/pyclass.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ fn extract_items_into_context<'a, Item>(
8181
{
8282
for item in items {
8383
let r = item.try_split_attr_mut(|attrs, item| {
84-
let (pyitems, cfgs) = attrs_to_content_items(attrs, impl_item_new::<Item>)?;
85-
for pyitem in pyitems.iter().rev() {
86-
let r = pyitem.gen_impl_item(ImplItemArgs::<Item> {
84+
let (py_items, cfgs) = attrs_to_content_items(attrs, impl_item_new::<Item>)?;
85+
for py_item in py_items.iter().rev() {
86+
let r = py_item.gen_impl_item(ImplItemArgs::<Item> {
8787
item,
8888
attrs,
8989
context,
@@ -393,6 +393,7 @@ pub(crate) fn impl_define_exception(exc_def: PyExceptionDef) -> Result<TokenStre
393393
// We need this method, because of how `CPython` copies `__init__`
394394
// from `BaseException` in `SimpleExtendsException` macro.
395395
// See: `(initproc)BaseException_init`
396+
// spell-checker:ignore initproc
396397
let init_method = match init {
397398
Some(init_def) => quote! { #init_def(zelf, args, vm) },
398399
None => quote! { #base_class::init(zelf, args, vm) },
@@ -553,7 +554,7 @@ where
553554
quote_spanned! { ident.span() =>
554555
class.set_attr(
555556
ctx.names.#name_ident,
556-
ctx.make_funcdef(#py_name, Self::#ident)
557+
ctx.make_func_def(#py_name, Self::#ident)
557558
#doc
558559
#build_func
559560
.into(),
@@ -563,7 +564,7 @@ where
563564
quote_spanned! { ident.span() =>
564565
class.set_str_attr(
565566
#py_name,
566-
ctx.make_funcdef(#py_name, Self::#ident)
567+
ctx.make_func_def(#py_name, Self::#ident)
567568
#doc
568569
#build_func,
569570
ctx,
@@ -1048,8 +1049,8 @@ impl ItemMeta for SlotItemMeta {
10481049
where
10491050
I: std::iter::Iterator<Item = NestedMeta>,
10501051
{
1051-
let meta_map = if let Some(nmeta) = nested.next() {
1052-
match nmeta {
1052+
let meta_map = if let Some(nested_meta) = nested.next() {
1053+
match nested_meta {
10531054
NestedMeta::Meta(meta) => {
10541055
Some([("name".to_owned(), (0, meta))].iter().cloned().collect())
10551056
}
@@ -1059,7 +1060,7 @@ impl ItemMeta for SlotItemMeta {
10591060
Some(HashMap::default())
10601061
};
10611062
let (Some(meta_map), None) = (meta_map, nested.next()) else {
1062-
bail_span!(meta_ident, "#[pyslot] must be of the form #[pyslot] or #[pyslot(slotname)]")
1063+
bail_span!(meta_ident, "#[pyslot] must be of the form #[pyslot] or #[pyslot(slot_name)]")
10631064
};
10641065
Ok(Self::from_inner(ItemMetaInner {
10651066
item_ident,
@@ -1096,7 +1097,7 @@ impl SlotItemMeta {
10961097
slot_name.ok_or_else(|| {
10971098
err_span!(
10981099
inner.meta_ident,
1099-
"#[pyslot] must be of the form #[pyslot] or #[pyslot(slotname)]",
1100+
"#[pyslot] must be of the form #[pyslot] or #[pyslot(slot_name)]",
11001101
)
11011102
})
11021103
}

0 commit comments

Comments
 (0)