Skip to content

Commit

Permalink
don't show "X defined here" when error context is hidden.
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland committed Aug 26, 2023
1 parent 33f11b7 commit e266d15
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### Added
### Enhancements
### Fixes
- Don't show "X defined here" when error context is hidden (#498)

## [2.0.0]
### Added
Expand Down
2 changes: 1 addition & 1 deletion mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ def unexpected_keyword_argument(
msg += f"; did you mean {pretty_seq(matches, 'or')}?"
self.fail(msg, context, code=codes.CALL_ARG)
module = find_defining_module(self.modules, callee)
if module:
if module and (not mypy.options._based or self.options.show_error_context):
assert callee.definition is not None
fname = callable_name(callee)
if not fname: # an alias to function with a different name
Expand Down
1 change: 1 addition & 0 deletions test-data/unit/check-based-infer-function-types.test
Original file line number Diff line number Diff line change
Expand Up @@ -481,5 +481,6 @@ def f1():


[case testNotesAppearForInferredFunction]
# flags: --show-error-context
def f(): ... # N: "f" defined here
f(x=1) # E: Unexpected keyword argument "x" for "f" [call-arg]
8 changes: 8 additions & 0 deletions test-data/unit/check-based-misc.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[case testXDefinedHere]
# mypy: show-error-context
import a
def f(): ... # N: "f" defined here
f(a=1) # E: Unexpected keyword argument "a" for "f" [call-arg]
[file a.py]
def f(): ...
f(a=1) # E: Unexpected keyword argument "a" for "f" [call-arg]
4 changes: 2 additions & 2 deletions test-data/unit/cmdline-based-baseline.test
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ foo()
}

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

[case testSrcOtherFile2]
# cmd: mypy a.py
# cmd: mypy a.py --show-error-context
[file a.py]
from b import f
f(a=1)
Expand Down

0 comments on commit e266d15

Please sign in to comment.