-
Notifications
You must be signed in to change notification settings - Fork 249
Fix match case dict pattern error after matching None (#2058) #2059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix match case dict pattern error after matching None (#2058) #2059
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! LGTM, I'll try to get it landed
This comment has been minimized.
This comment has been minimized.
|
Thanks for the quick PR. Would it also allow the following variant? I've used this construct in my code. No errors reported by pyright and mypy. And Python handles it fine too. match dict_or_none:
case {"a": "b"}: # Object of class `NoneType` has no attribute `__getitem__`
pass
case None:
pass
case _:
pass |
Good catch! Yeah this fix only handles the case where None comes first. The reverse order would need a different approach to fix, would look into it as well |
|
as per my assumptions, MatchMapping itself needs to filter out non-mapping types (like None) BEFORE calling getitem similar to how MatchSequence uses LenEq to filter out non-sequences. |
yangdanny97
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review automatically exported from Phabricator review in Meta.
|
Maybe we could add a IsMapping/IsNotMapping narrowing op like #2049 does for sequences |
|
From the PEP: For a mapping pattern to succeed the subject must be a mapping, where being a mapping is defined as its class being one of the following:
The standard library classes dict and mappingproxy will have their Py_TPFLAGS_MAPPING bit set. My thoughts: I think checking if it extends |
Done! Added IsMapping/IsNotMapping narrowing op that checks against typing.Mapping, Also added a test for the reverse case (dict pattern before None). |
1a10da7 to
c82ebec
Compare
Signed-off-by: Aryan Bagade <[email protected]>
Signed-off-by: Aryan Bagade <[email protected]>
c82ebec to
b33d2e9
Compare
|
Diff from mypy_primer, showing the effect of this PR on open source code: schema_salad (https://github.com/common-workflow-language/schema_salad)
- ERROR schema_salad/dotnet_codegen.py:439:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:439:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:439:73-80: No matching overload found for function `list.__getitem__` called with arguments: (Literal['items']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:439:73-80: No matching overload found for function `str.__getitem__` called with arguments: (Literal['items']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:449:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:449:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:449:69-77: No matching overload found for function `list.__getitem__` called with arguments: (Literal['values']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:449:69-77: No matching overload found for function `str.__getitem__` called with arguments: (Literal['values']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:466:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:466:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:469:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:469:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:470:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:470:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:485:45-53: Object of class `list` has no attribute `get`
- Object of class `str` has no attribute `get` [missing-attribute]
- ERROR schema_salad/dotnet_codegen.py:489:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:489:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:490:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:490:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:491:17-24: No matching overload found for function `list.__getitem__` called with arguments: (Literal['names']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:491:17-24: No matching overload found for function `str.__getitem__` called with arguments: (Literal['names']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:514:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/dotnet_codegen.py:514:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:459:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:459:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:459:73-80: No matching overload found for function `list.__getitem__` called with arguments: (Literal['items']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:459:73-80: No matching overload found for function `str.__getitem__` called with arguments: (Literal['items']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:476:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:476:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:476:69-77: No matching overload found for function `list.__getitem__` called with arguments: (Literal['values']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:476:69-77: No matching overload found for function `str.__getitem__` called with arguments: (Literal['values']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:495:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:495:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:499:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:499:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:500:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:500:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:503:31-39: Object of class `list` has no attribute `get`
- Object of class `str` has no attribute `get` [missing-attribute]
- ERROR schema_salad/java_codegen.py:524:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:524:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:525:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:525:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:526:17-24: No matching overload found for function `list.__getitem__` called with arguments: (Literal['names']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:526:17-24: No matching overload found for function `str.__getitem__` called with arguments: (Literal['names']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:592:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/java_codegen.py:592:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:396:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:396:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:396:73-80: No matching overload found for function `list.__getitem__` called with arguments: (Literal['items']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:396:73-80: No matching overload found for function `str.__getitem__` called with arguments: (Literal['items']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:404:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:404:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:404:69-77: No matching overload found for function `list.__getitem__` called with arguments: (Literal['values']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:404:69-77: No matching overload found for function `str.__getitem__` called with arguments: (Literal['values']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:406:43-55: Cannot index into `list[Any]` [bad-index]
- ERROR schema_salad/python_codegen.py:406:43-55: Cannot index into `str` [bad-index]
- ERROR schema_salad/python_codegen.py:420:52-64: Cannot index into `list[Any]` [bad-index]
- ERROR schema_salad/python_codegen.py:420:52-64: Cannot index into `str` [bad-index]
- ERROR schema_salad/python_codegen.py:425:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:425:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:426:17-26: No matching overload found for function `list.__getitem__` called with arguments: (Literal['symbols']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:426:17-26: No matching overload found for function `str.__getitem__` called with arguments: (Literal['symbols']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:427:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:427:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:433:34-45: Cannot index into `list[Any]` [bad-index]
- ERROR schema_salad/python_codegen.py:433:34-45: Cannot index into `str` [bad-index]
- ERROR schema_salad/python_codegen.py:452:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:452:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:452:75-81: No matching overload found for function `list.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:452:75-81: No matching overload found for function `str.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:461:39-47: Object of class `list` has no attribute `get`
- Object of class `str` has no attribute `get` [missing-attribute]
- ERROR schema_salad/python_codegen.py:466:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:466:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:467:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:467:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:468:17-24: No matching overload found for function `list.__getitem__` called with arguments: (Literal['names']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:468:17-24: No matching overload found for function `str.__getitem__` called with arguments: (Literal['names']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:484:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/python_codegen.py:484:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:379:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:379:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:379:73-80: No matching overload found for function `list.__getitem__` called with arguments: (Literal['items']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:379:73-80: No matching overload found for function `str.__getitem__` called with arguments: (Literal['items']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:388:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:388:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:388:69-77: No matching overload found for function `list.__getitem__` called with arguments: (Literal['values']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:388:69-77: No matching overload found for function `str.__getitem__` called with arguments: (Literal['values']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:406:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:406:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:410:19-25: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:410:19-25: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:410:75-81: No matching overload found for function `list.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:410:75-81: No matching overload found for function `str.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:428:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:428:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['type']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:429:17-23: No matching overload found for function `list.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:429:17-23: No matching overload found for function `str.__getitem__` called with arguments: (Literal['name']) [no-matching-overload]
- ERROR schema_salad/typescript_codegen.py:430:17-24: No matching overload found for function `list.__getitem__` called with arguments: (Literal['names']) [no-matching-overload]
... (truncated 104 lines) ...
cwltool (https://github.com/common-workflow-language/cwltool)
- ERROR cwltool/builder.py:649:19-26: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/checker.py:90:15-21: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
+ ERROR cwltool/cwlprov/provenance_profile.py:478:44-49: Argument `Mapping[Unknown, Unknown]` is not assignable to parameter `value` with type `MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None]` in function `ProvenanceProfile.declare_file` [bad-argument-type]
+ ERROR cwltool/cwlprov/provenance_profile.py:479:17-29: Cannot set item in `Mapping[Unknown, Unknown]` [unsupported-operation]
+ ERROR cwltool/cwlprov/provenance_profile.py:482:49-54: Argument `Mapping[Unknown, Unknown]` is not assignable to parameter `value` with type `MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None]` in function `ProvenanceProfile.declare_directory` [bad-argument-type]
+ ERROR cwltool/cwlprov/provenance_profile.py:483:17-29: Cannot set item in `Mapping[Unknown, Unknown]` [unsupported-operation]
+ ERROR cwltool/cwlprov/provenance_profile.py:486:27-43: Object of class `Mapping` has no attribute `setdefault` [missing-attribute]
- ERROR cwltool/load_tool.py:148:15-22: No matching overload found for function `typing.MutableSequence.__getitem__` called with arguments: (Literal['class']) [no-matching-overload]
- ERROR cwltool/load_tool.py:148:15-22: No matching overload found for function `str.__getitem__` called with arguments: (Literal['class']) [no-matching-overload]
- ERROR cwltool/load_tool.py:155:27-35: Object of class `MutableSequence` has no attribute `get`
- Object of class `str` has no attribute `get` [missing-attribute]
- ERROR cwltool/load_tool.py:169:44-60: Cannot index into `MutableSequence[MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None] | int | str]` [bad-index]
- ERROR cwltool/load_tool.py:169:44-60: Cannot index into `str` [bad-index]
- ERROR cwltool/load_tool.py:179:61-69: Object of class `MutableSequence` has no attribute `get`
- Object of class `str` has no attribute `get` [missing-attribute]
- ERROR cwltool/main.py:212:15-21: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/main.py:212:32-39: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/main.py:229:15-21: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/main.py:229:31-40: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/main.py:232:18-35: `in` is not supported between `Literal['default']` and `bool` [not-iterable]
- ERROR cwltool/main.py:232:18-35: `in` is not supported between `Literal['default']` and `float` [not-iterable]
- ERROR cwltool/main.py:232:18-35: `in` is not supported between `Literal['default']` and `int` [not-iterable]
- ERROR cwltool/main.py:232:18-35: `in` is not supported between `Literal['default']` and `None` [not-iterable]
- ERROR cwltool/main.py:233:27-42: Cannot index into `MutableSequence[Unknown]` [bad-index]
- ERROR cwltool/main.py:233:27-42: Cannot index into `bool` [bad-index]
- ERROR cwltool/main.py:233:27-42: Cannot index into `float` [bad-index]
- ERROR cwltool/main.py:233:27-42: Cannot index into `int` [bad-index]
- ERROR cwltool/main.py:233:27-42: Cannot index into `str` [bad-index]
- ERROR cwltool/main.py:233:27-42: `None` is not subscriptable [unsupported-operation]
- ERROR cwltool/main.py:237:50-58: Object of class `MutableSequence` has no attribute `get`
- Object of class `NoneType` has no attribute `get`
- Object of class `bool` has no attribute `get`
- Object of class `float` has no attribute `get`
- Object of class `int` has no attribute `get`
- Object of class `str` has no attribute `get` [missing-attribute]
- ERROR cwltool/main.py:239:15-21: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/main.py:239:33-41: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/main.py:241:16-30: `in` is not supported between `Literal['name']` and `bool` [not-iterable]
- ERROR cwltool/main.py:241:16-30: `in` is not supported between `Literal['name']` and `float` [not-iterable]
- ERROR cwltool/main.py:241:16-30: `in` is not supported between `Literal['name']` and `int` [not-iterable]
- ERROR cwltool/main.py:241:16-30: `in` is not supported between `Literal['name']` and `None` [not-iterable]
- ERROR cwltool/main.py:242:54-66: Cannot index into `MutableSequence[Unknown]` [bad-index]
- ERROR cwltool/main.py:242:54-66: Cannot index into `bool` [bad-index]
- ERROR cwltool/main.py:242:54-66: Cannot index into `float` [bad-index]
- ERROR cwltool/main.py:242:54-66: Cannot index into `int` [bad-index]
- ERROR cwltool/main.py:242:54-66: Cannot index into `str` [bad-index]
- ERROR cwltool/main.py:242:54-66: `None` is not subscriptable [unsupported-operation]
- ERROR cwltool/main.py:248:15-21: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/main.py:248:38-47: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/main.py:251:15-21: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/process.py:438:15-21: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/process.py:439:16-34: `not in` is not supported between `Literal['name']` and `bool` [not-iterable]
- ERROR cwltool/process.py:439:16-34: `not in` is not supported between `Literal['name']` and `float` [not-iterable]
- ERROR cwltool/process.py:439:16-34: `not in` is not supported between `Literal['name']` and `int` [not-iterable]
- ERROR cwltool/process.py:439:16-34: `not in` is not supported between `Literal['name']` and `None` [not-iterable]
- ERROR cwltool/process.py:443:58-72: Cannot index into `MutableSequence[Any]` [bad-index]
- ERROR cwltool/process.py:443:58-72: Cannot index into `MutableSequence[Unknown]` [bad-index]
- ERROR cwltool/process.py:443:58-72: Cannot index into `bool` [bad-index]
- ERROR cwltool/process.py:443:58-72: Cannot index into `float` [bad-index]
- ERROR cwltool/process.py:443:58-72: Cannot index into `int` [bad-index]
- ERROR cwltool/process.py:443:58-72: Cannot index into `str` [bad-index]
- ERROR cwltool/process.py:443:58-72: `None` is not subscriptable [unsupported-operation]
- ERROR cwltool/process.py:445:15-21: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/process.py:445:32-39: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ERROR cwltool/process.py:449:15-21: Object of class `NoneType` has no attribute `__getitem__`
- Object of class `bool` has no attribute `__getitem__`
- Object of class `float` has no attribute `__getitem__`
- Object of class `int` has no attribute `__getitem__` [missing-attribute]
- ::error file=cwltool/builder.py,line=649,col=19,endLine=649,endColumn=26,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `__getitem__`%0AObject of class `bool` has no attribute `__getitem__`%0AObject of class `float` has no attribute `__getitem__`%0AObject of class `int` has no attribute `__getitem__`%0A Did you mean `__setitem__`?
- ::error file=cwltool/checker.py,line=90,col=15,endLine=90,endColumn=21,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `__getitem__`%0AObject of class `bool` has no attribute `__getitem__`%0AObject of class `float` has no attribute `__getitem__`%0AObject of class `int` has no attribute `__getitem__`%0A Did you mean `__setitem__`?
+ ::error file=cwltool/cwlprov/provenance_profile.py,line=478,col=44,endLine=478,endColumn=49,title=Pyrefly bad-argument-type::Argument `Mapping[Unknown, Unknown]` is not assignable to parameter `value` with type `MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None]` in function `ProvenanceProfile.declare_file`
+ ::error file=cwltool/cwlprov/provenance_profile.py,line=479,col=17,endLine=479,endColumn=29,title=Pyrefly unsupported-operation::Cannot set item in `Mapping[Unknown, Unknown]`%0A Object of class `Mapping` has no attribute `__setitem__`%0A Did you mean `__getitem__`?
+ ::error file=cwltool/cwlprov/provenance_profile.py,line=482,col=49,endLine=482,endColumn=54,title=Pyrefly bad-argument-type::Argument `Mapping[Unknown, Unknown]` is not assignable to parameter `value` with type `MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None]` in function `ProvenanceProfile.declare_directory`
+ ::error file=cwltool/cwlprov/provenance_profile.py,line=483,col=17,endLine=483,endColumn=29,title=Pyrefly unsupported-operation::Cannot set item in `Mapping[Unknown, Unknown]`%0A Object of class `Mapping` has no attribute `__setitem__`%0A Did you mean `__getitem__`?
+ ::error file=cwltool/cwlprov/provenance_profile.py,line=486,col=27,endLine=486,endColumn=43,title=Pyrefly missing-attribute::Object of class `Mapping` has no attribute `setdefault`
- ::error file=cwltool/load_tool.py,line=148,col=15,endLine=148,endColumn=22,title=Pyrefly no-matching-overload::No matching overload found for function `typing.MutableSequence.__getitem__` called with arguments: (Literal['class'])%0A Possible overloads:%0A (index: int) -> MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None] | int | str [closest match]%0A (index: slice[Any, Any, Any]) -> MutableSequence[MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None] | int | str]
- ::error file=cwltool/load_tool.py,line=148,col=15,endLine=148,endColumn=22,title=Pyrefly no-matching-overload::No matching overload found for function `str.__getitem__` called with arguments: (Literal['class'])%0A Possible overloads:%0A (key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString%0A (key: SupportsIndex | slice[Any, Any, Any], /) -> str [closest match]
- ::error file=cwltool/load_tool.py,line=155,col=27,endLine=155,endColumn=35,title=Pyrefly missing-attribute::Object of class `MutableSequence` has no attribute `get`%0AObject of class `str` has no attribute `get`
- ::error file=cwltool/load_tool.py,line=169,col=44,endLine=169,endColumn=60,title=Pyrefly bad-index::Cannot index into `MutableSequence[MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None] | int | str]`%0A No matching overload found for function `typing.MutableSequence.__getitem__` called with arguments: (str)%0A Possible overloads:%0A (index: int) -> MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None] | int | str [closest match]%0A (index: slice[Any, Any, Any]) -> MutableSequence[MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None] | int | str]
- ::error file=cwltool/load_tool.py,line=169,col=44,endLine=169,endColumn=60,title=Pyrefly bad-index::Cannot index into `str`%0A No matching overload found for function `str.__getitem__` called with arguments: (str)%0A Possible overloads:%0A (key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString%0A (key: SupportsIndex | slice[Any, Any, Any], /) -> str [closest match]
- ::error file=cwltool/load_tool.py,line=179,col=61,endLine=179,endColumn=69,title=Pyrefly missing-attribute::Object of class `MutableSequence` has no attribute `get`%0AObject of class `str` has no attribute `get`
- ::error file=cwltool/main.py,line=212,col=15,endLine=212,endColumn=21,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `__getitem__`%0AObject of class `bool` has no attribute `__getitem__`%0AObject of class `float` has no attribute `__getitem__`%0AObject of class `int` has no attribute `__getitem__`%0A Did you mean `__setitem__`?
- ::error file=cwltool/main.py,line=212,col=32,endLine=212,endColumn=39,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `__getitem__`%0AObject of class `bool` has no attribute `__getitem__`%0AObject of class `float` has no attribute `__getitem__`%0AObject of class `int` has no attribute `__getitem__`%0A Did you mean `__setitem__`?
- ::error file=cwltool/main.py,line=229,col=15,endLine=229,endColumn=21,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `__getitem__`%0AObject of class `bool` has no attribute `__getitem__`%0AObject of class `float` has no attribute `__getitem__`%0AObject of class `int` has no attribute `__getitem__`%0A Did you mean `__setitem__`?
- ::error file=cwltool/main.py,line=229,col=31,endLine=229,endColumn=40,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `__getitem__`%0AObject of class `bool` has no attribute `__getitem__`%0AObject of class `float` has no attribute `__getitem__`%0AObject of class `int` has no attribute `__getitem__`%0A Did you mean `__setitem__`?
- ::error file=cwltool/main.py,line=232,col=18,endLine=232,endColumn=35,title=Pyrefly not-iterable::`in` is not supported between `Literal['default']` and `bool`
- ::error file=cwltool/main.py,line=232,col=18,endLine=232,endColumn=35,title=Pyrefly not-iterable::`in` is not supported between `Literal['default']` and `float`
- ::error file=cwltool/main.py,line=232,col=18,endLine=232,endColumn=35,title=Pyrefly not-iterable::`in` is not supported between `Literal['default']` and `int`
- ::error file=cwltool/main.py,line=232,col=18,endLine=232,endColumn=35,title=Pyrefly not-iterable::`in` is not supported between `Literal['default']` and `None`
... (truncated 37 lines) ...
pytest (https://github.com/pytest-dev/pytest)
- ERROR src/_pytest/unittest.py:419:30-41: Argument `ExceptionInfo[BaseException] | tuple[type[BaseException], BaseException, TracebackType] | None` is not assignable to parameter `arg` with type `Never` in function `typing.assert_never` [bad-argument-type]
- ::error file=src/_pytest/unittest.py,line=419,col=30,endLine=419,endColumn=41,title=Pyrefly bad-argument-type::Argument `ExceptionInfo[BaseException] | tuple[type[BaseException], BaseException, TracebackType] | None` is not assignable to parameter `arg` with type `Never` in function `typing.assert_never`
|
|
@yangdanny97 no hurry, just review once you get time! |
The fix creates a narrowed subject_idx for each case by applying the accumulated negated_prev_ops before passing it to bind_pattern - following the same pattern already used by MatchSequence and MatchClass.
Fixes #2058
Test Plan