Skip to content

Commit 5d053ad

Browse files
committed
Add NotNone to params
1 parent c6e84d5 commit 5d053ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+145
-139
lines changed

src/core/IronPython.Modules/IterTools.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public class chain : IterBase {
142142

143143
private chain() { }
144144

145-
public chain(params object[] iterables) {
145+
public chain([NotNone] params object[] iterables) {
146146
SetInnerEnumerator(PythonTuple.MakeTuple(iterables));
147147
}
148148

@@ -667,15 +667,15 @@ public class zip_longest : IEnumerator {
667667
private readonly object _fill;
668668
private PythonTuple _current;
669669

670-
public zip_longest(params object[] iterables) {
670+
public zip_longest([NotNone] params object[] iterables) {
671671
_iters = new IEnumerator[iterables.Length];
672672

673673
for (int i = 0; i < iterables.Length; i++) {
674674
_iters[i] = PythonOps.GetEnumerator(iterables[i]);
675675
}
676676
}
677677

678-
public zip_longest([ParamDictionary] IDictionary<object, object> paramDict, params object[] iterables) {
678+
public zip_longest([ParamDictionary] IDictionary<object, object> paramDict, [NotNone] params object[] iterables) {
679679
object fill;
680680

681681
if (paramDict.TryGetValue("fillvalue", out fill)) {
@@ -762,12 +762,12 @@ private static Exception UnexpectedKeywordArgument(IDictionary<object, object> p
762762
public class product : IterBase {
763763
private PythonTuple[] tuples;
764764

765-
public product(CodeContext context, params object[] iterables) {
765+
public product(CodeContext context, [NotNone] params object[] iterables) {
766766
tuples = ArrayUtils.ConvertAll(iterables, x => new PythonTuple(PythonOps.GetEnumerator(x)));
767767
InnerEnumerator = Yielder(tuples);
768768
}
769769

770-
public product(CodeContext context, [ParamDictionary] IDictionary<object, object> paramDict, params object[] iterables) {
770+
public product(CodeContext context, [ParamDictionary] IDictionary<object, object> paramDict, [NotNone] params object[] iterables) {
771771
object repeat;
772772
int iRepeat = 1;
773773
if (paramDict.TryGetValue("repeat", out repeat)) {

src/core/IronPython.Modules/ResourceMetaPathImporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fully qualified (dotted) module name. It returns the importer
7474
The optional 'path' argument is ignored -- it's there for compatibility
7575
with the importer protocol."
7676
)]
77-
public object find_module(CodeContext /*!*/ context, string fullname, params object[] args) {
77+
public object find_module(CodeContext /*!*/ context, string fullname, [NotNone] params object[] args) {
7878
var packedName = MakeFilename(fullname);
7979

8080
foreach (var entry in SearchOrder) {

src/core/IronPython.Modules/_collections.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private deque(int maxlen) {
4141
_data = _maxLen < 0 ? new object[8] : new object[Math.Min(_maxLen, 8)];
4242
}
4343

44-
public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDictionary] IDictionary<object, object> dict, params object[] args) {
44+
public static object __new__(CodeContext/*!*/ context, PythonType cls, [ParamDictionary] IDictionary<object, object> dict, [NotNone] params object[] args) {
4545
if (cls == DynamicHelpers.GetPythonTypeFromType(typeof(deque))) return new deque();
4646
return cls.CreateInstance(context);
4747
}
@@ -1148,15 +1148,15 @@ public defaultdict(CodeContext/*!*/ context) {
11481148
this.default_factory = default_factory;
11491149
}
11501150

1151-
public void __init__(CodeContext/*!*/ context, object default_factory, params object[] args) {
1151+
public void __init__(CodeContext/*!*/ context, object default_factory, [NotNone] params object[] args) {
11521152
__init__(context, default_factory);
11531153

11541154
foreach (object o in args) {
11551155
update(context, o);
11561156
}
11571157
}
11581158

1159-
public void __init__(CodeContext/*!*/ context, object default_factory, [ParamDictionary] IDictionary<object, object> dict, params object[] args) {
1159+
public void __init__(CodeContext/*!*/ context, object default_factory, [ParamDictionary] IDictionary<object, object> dict, [NotNone] params object[] args) {
11601160
__init__(context, default_factory, args);
11611161

11621162
foreach (KeyValuePair<object, object> kvp in dict) {

src/core/IronPython.Modules/_csv.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static int field_size_limit(CodeContext/*!*/ context) {
6464
dialect = csv.register_dialect(name, dialect)")]
6565
public static void register_dialect(CodeContext/*!*/ context,
6666
[ParamDictionary] IDictionary<object, object> kwArgs,
67-
params object[] args) {
67+
[NotNone] params object[] args) {
6868
string name = null;
6969
object dialectObj = null;
7070
Dialect dialect = null;
@@ -157,7 +157,7 @@ The returned object is an iterator. Each iteration returns a row
157157
of the CSV file (which can span multiple input lines)")]
158158
public static object reader(CodeContext/*!*/ context,
159159
[ParamDictionary] IDictionary<object, object> kwArgs,
160-
params object[] args) {
160+
[NotNone] params object[] args) {
161161
object dialectObj = null;
162162
Dialect dialect = null;
163163
IEnumerator e = null;
@@ -198,7 +198,7 @@ public static object reader(CodeContext/*!*/ context,
198198

199199
public static object writer(CodeContext/*!*/ context,
200200
[ParamDictionary] IDictionary<object, object> kwArgs,
201-
params object[] args) {
201+
[NotNone] params object[] args) {
202202
object output_file = null;
203203
object dialectObj = null;
204204
Dialect dialect = null;
@@ -416,7 +416,7 @@ private static string SetString(string name, object src, bool found, string @def
416416

417417
public Dialect(CodeContext/*!*/ context,
418418
[ParamDictionary] IDictionary<object, object> kwArgs,
419-
params object[] args) {
419+
[NotNone] params object[] args) {
420420
object dialect = null;
421421
object delimiter = null;
422422
object doublequote = null;
@@ -507,10 +507,10 @@ public Dialect(CodeContext/*!*/ context,
507507

508508
// CPython defines these overloads on Dialect since 3.10
509509
[Documentation("raises an exception to avoid pickling")]
510-
public object __reduce__(params object[] args) => throw PythonOps.TypeError("cannot pickle 'Dialect' instances");
510+
public object __reduce__([NotNone] params object[] args) => throw PythonOps.TypeError("cannot pickle 'Dialect' instances");
511511

512512
[Documentation("raises an exception to avoid pickling")]
513-
public object __reduce_ex__(params object[] args) => throw PythonOps.TypeError("cannot pickle 'Dialect' instances");
513+
public object __reduce_ex__([NotNone] params object[] args) => throw PythonOps.TypeError("cannot pickle 'Dialect' instances");
514514

515515
public string escapechar {
516516
get { return _escapechar; }

src/core/IronPython.Modules/_ctypes/Array.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static partial class CTypes {
2323
[PythonType("Array")]
2424
public abstract class _Array : CData {
2525

26-
public void __init__(params object[] args) {
26+
public void __init__([NotNone] params object[] args) {
2727
INativeType nativeType = NativeType;
2828

2929
MemHolder = new MemoryHolder(nativeType.Size);

src/core/IronPython.Modules/_ctypes/Structure.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected _Structure() {
4444
MemHolder = new MemoryHolder(NativeType.Size);
4545
}
4646

47-
public void __init__(params object[] args) {
47+
public void __init__([NotNone] params object[] args) {
4848
CheckAbstract();
4949

5050
INativeType nativeType = NativeType;

src/core/IronPython.Modules/_ctypes/_ctypes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ public class _COMError : PythonExceptions.BaseException {
770770

771771
public _COMError(PythonType cls) : base(cls) { }
772772

773-
public override void __init__(params object[] args) {
773+
public override void __init__([NotNone] params object[] args) {
774774
base.__init__(args);
775775
if (args.Length < 3) {
776776
throw PythonOps.TypeError($"COMError() takes exactly 4 arguments({args.Length} given)");

src/core/IronPython.Modules/_datetime.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ public datetime(DateTime dt, tzinfo? tzinfo)
679679
}
680680

681681
// just present to match CPython's error messages...
682-
public datetime(params object[] args) {
682+
public datetime([NotNone] params object[] args) {
683683
if (args.Length < 3) {
684684
throw PythonOps.TypeError("function takes at least 3 arguments ({0} given)", args.Length);
685685
} else if (args.Length > 8) {
@@ -1447,10 +1447,10 @@ public class tzinfo {
14471447
public tzinfo() {
14481448
}
14491449

1450-
public tzinfo(params object?[] args) {
1450+
public tzinfo([NotNone] params object?[] args) {
14511451
}
14521452

1453-
public tzinfo([ParamDictionary] PythonDictionary dict, params object?[] args) {
1453+
public tzinfo([ParamDictionary] PythonDictionary dict, [NotNone] params object?[] args) {
14541454
}
14551455

14561456
public virtual object fromutc([NotNone] datetime dt) {

src/core/IronPython.Modules/_functools.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ public class partial : IWeakReferenceable {
8989
/// <summary>
9090
/// Creates a new partial object with the provided positional arguments.
9191
/// </summary>
92-
public partial(CodeContext/*!*/ context, object? func, params object[] args)
92+
public partial(CodeContext/*!*/ context, object? func, [NotNone] params object[] args)
9393
: this(context, func, new PythonDictionary(), args) {
9494
}
9595

9696
/// <summary>
9797
/// Creates a new partial object with the provided positional and keyword arguments.
9898
/// </summary>
99-
public partial(CodeContext/*!*/ context, object? func, [ParamDictionary] IDictionary<object, object> keywords, params object[] args) {
99+
public partial(CodeContext/*!*/ context, object? func, [ParamDictionary] IDictionary<object, object> keywords, [NotNone] params object[] args) {
100100
if (!PythonOps.IsCallable(context, func)) {
101101
throw PythonOps.TypeError("the first argument must be callable");
102102
}
@@ -230,7 +230,7 @@ public string __repr__(CodeContext context) {
230230
/// Calls func with the previously provided arguments and more positional arguments.
231231
/// </summary>
232232
[SpecialName]
233-
public object? Call(CodeContext/*!*/ context, params object?[] args) {
233+
public object? Call(CodeContext/*!*/ context, [NotNone] params object?[] args) {
234234
if (_keywordArgs == null) {
235235
EnsureSplatSite();
236236
return _splatSite!.Target(_splatSite, context, func, ArrayUtils.AppendRange(_args, args));
@@ -244,7 +244,7 @@ public string __repr__(CodeContext context) {
244244
/// Calls func with the previously provided arguments and more positional arguments and keyword arguments.
245245
/// </summary>
246246
[SpecialName]
247-
public object? Call(CodeContext/*!*/ context, [ParamDictionary] IDictionary<object, object?> dict, params object?[] args) {
247+
public object? Call(CodeContext/*!*/ context, [ParamDictionary] IDictionary<object, object?> dict, [NotNone] params object?[] args) {
248248

249249
IDictionary<object, object?> finalDict;
250250
if (_keywordArgs != null) {

src/core/IronPython.Modules/_operator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static class PythonOperator {
2727
public sealed class attrgetter : ICodeFormattable {
2828
private readonly object[] _names;
2929

30-
public attrgetter(params object[] attrs) {
30+
public attrgetter([NotNone] params object[] attrs) {
3131
if (attrs == null || !attrs.All(x => x is string)) throw PythonOps.TypeError("attribute name must be a string");
3232
if (attrs.Length == 0) throw PythonOps.TypeError("attrgetter expected 1 arguments, got 0");
3333

@@ -70,7 +70,7 @@ public attrgetter(params object[] attrs) {
7070
public sealed class itemgetter : ICodeFormattable {
7171
private readonly object?[] _items;
7272

73-
public itemgetter(params object?[] items) {
73+
public itemgetter([NotNone] params object?[] items) {
7474
if (items.Length == 0) {
7575
throw PythonOps.TypeError("itemgetter needs at least one argument");
7676
}
@@ -104,15 +104,15 @@ public sealed class methodcaller : ICodeFormattable {
104104
private readonly object?[] _args;
105105
private readonly IDictionary<object, object>? _dict;
106106

107-
public methodcaller(params object?[] args) {
107+
public methodcaller([NotNone] params object?[] args) {
108108
if (args == null) throw PythonOps.TypeError("TypeError: method name must be a string");
109109
if (args.Length == 0) throw PythonOps.TypeError("methodcaller needs at least one argument, the method name");
110110
if (args[0] is not string name) throw PythonOps.TypeError("TypeError: method name must be a string");
111111
_name = name;
112112
_args = args.Skip(1).ToArray();
113113
}
114114

115-
public methodcaller([ParamDictionary] IDictionary<object, object> kwargs, params object?[] args) : this(args) {
115+
public methodcaller([ParamDictionary] IDictionary<object, object> kwargs, [NotNone] params object?[] args) : this(args) {
116116
_dict = kwargs;
117117
}
118118

0 commit comments

Comments
 (0)