Skip to content

Commit bcce267

Browse files
committed
don't show "X defined here" when error context is hidden.
1 parent 33f11b7 commit bcce267

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
### Added
55
### Enhancements
66
### Fixes
7+
- Don't show "X defined here" when error context is hidden (#498)
8+
9+
## [2.1.0]
710

811
## [2.0.0]
912
### Added

mypy/messages.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ def unexpected_keyword_argument(
10401040
msg += f"; did you mean {pretty_seq(matches, 'or')}?"
10411041
self.fail(msg, context, code=codes.CALL_ARG)
10421042
module = find_defining_module(self.modules, callee)
1043-
if module:
1043+
if module and (not mypy.options._based or self.options.show_error_context):
10441044
assert callee.definition is not None
10451045
fname = callable_name(callee)
10461046
if not fname: # an alias to function with a different name

test-data/unit/check-based-infer-function-types.test

+1
Original file line numberDiff line numberDiff line change
@@ -481,5 +481,6 @@ def f1():
481481

482482

483483
[case testNotesAppearForInferredFunction]
484+
# flags: --show-error-context
484485
def f(): ... # N: "f" defined here
485486
f(x=1) # E: Unexpected keyword argument "x" for "f" [call-arg]

test-data/unit/check-based-misc.test

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[case testXDefinedHere]
2+
# mypy: show-error-context
3+
import a
4+
def f(): ... # N: "f" defined here
5+
f(a=1) # E: Unexpected keyword argument "a" for "f" [call-arg]
6+
[file a.py]
7+
def f(): ...
8+
f(a=1) # E: Unexpected keyword argument "a" for "f" [call-arg]

test-data/unit/cmdline-based-baseline.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ foo()
528528
}
529529

530530
[case testSrcOtherFile]
531-
# cmd: mypy --write-baseline a.py
531+
# cmd: mypy --write-baseline a.py --show-error-context
532532
[file a.py]
533533
from b import f
534534
f(a=1)
@@ -544,7 +544,7 @@ Baseline successfully written to .mypy/baseline.json
544544
== Return code: 0
545545

546546
[case testSrcOtherFile2]
547-
# cmd: mypy a.py
547+
# cmd: mypy a.py --show-error-context
548548
[file a.py]
549549
from b import f
550550
f(a=1)

0 commit comments

Comments
 (0)