8000 Fix config file parsing of disallow_any/disallow_untyped_defs combination by JelleZijlstra · Pull Request #4076 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Fix config file parsing of disallow_any/disallow_untyped_defs combination #4076

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

Merged
merged 4 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix the bug
  • Loading branch information
JelleZijlstra committed Oct 9, 2017
commit 17f4df850ffe91ef018aa6a60b469819cd057fc2
8 changes: 7 additions & 1 deletion mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,13 @@ def parse_section(prefix: str, template: Options,
print("%s: %s: %s" % (prefix, key, err), file=sys.stderr)
continue
if key == 'disallow_any':
results['disallow_untyped_defs'] = v and 'unannotated' in v
# "disallow_any = " should disable all disallow_any options, including untyped defs,
# given in a more general config.
if not v:
results['disallow_untyped_defs'] = False
# If "unannotated" is explicitly given, turn on disallow_untyped_defs.
elif 'unannotated' in v:
results['disallow_untyped_defs'] = True
if key == 'silent_imports':
print("%s: silent_imports has been replaced by "
"ignore_missing_imports=True; follow_imports=skip" % prefix, file=sys.stderr)
Expand Down
4 changes: 3 additions & 1 deletion test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -1086,5 +1086,7 @@ a/b/c/d/e/__init__.py:1: error: "int" not callable
disallow_untyped_defs = True
disallow_any = generics
[file a.py]
def get_tasks(self): # E: Function is missing a type annotation
def get_tasks(self):
return 'whatever'
[out]
a.py:1: error: Function is missing a type annotation
0