remove 'need type annotation for setting' error message

This commit is contained in:
Maxim Kurnikov
2018-12-06 19:38:27 +03:00
parent d9a9e5208e
commit 94ddb8c864
2 changed files with 10 additions and 11 deletions

View File

@@ -50,15 +50,16 @@ def add_settings_to_django_conf_object(ctx: ClassDefContext,
if copied is None: if copied is None:
continue continue
ctx.cls.info.names[name] = copied ctx.cls.info.names[name] = copied
else: # else:
context = Context() # TODO: figure out suggestion to add type annotation
module, node_name = sym.node.fullname().rsplit('.', 1) # context = Context()
module_file = api.modules.get(module) # module, node_name = sym.node.fullname().rsplit('.', 1)
if module_file is None: # module_file = api.modules.get(module)
return None # if module_file is None:
context.set_line(sym.node) # return None
api.msg.report(f"Need type annotation for '{sym.node.name()}'", context, # context.set_line(sym.node)
severity='error', file=module_file.path) # api.msg.report(f"Need type annotation for '{sym.node.name()}'", context,
# severity='error', file=module_file.path)
ctx.cls.info.fallback_to_any = True ctx.cls.info.fallback_to_any = True

View File

@@ -40,8 +40,6 @@ reveal_type(settings.REGISTRY) # E: Revealed type is 'Union[main.Class, None]'
reveal_type(settings.LIST) # E: Revealed type is 'Any' reveal_type(settings.LIST) # E: Revealed type is 'Any'
reveal_type(settings.BASE_LIST) # E: Revealed type is 'Any' reveal_type(settings.BASE_LIST) # E: Revealed type is 'Any'
[out] [out]
mysettings:4: error: Need type annotation for 'LIST'
base:6: error: Need type annotation for 'BASE_LIST'
[env DJANGO_SETTINGS_MODULE=mysettings] [env DJANGO_SETTINGS_MODULE=mysettings]
[file mysettings.py] [file mysettings.py]