# Buggy code
def check_attribute_name(self, node: ast.ClassDef) -> None:
    top_level_assigns = [
        sub_node for sub_node in node.body if isinstance(sub_node, ast.Assign)
    ]

    for assignment in top_level_assigns:
        for target in assignment.targets:
            name = getattr(target, "id", None)
            if logical.is_upper_case_name(name):
                self._error_callback(
                    naming.UpperCaseAttributeViolation(target, text=name),
                )


# Traceback (TypeError)
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/checker.py", line 682, in _run_checks
return checker.run_checks()
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/checker.py", line 612, in run_checks
self.run_ast_checks()
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/checker.py", line 520, in run_ast_checks
for (line_number, offset, text, check) in runner:
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/checker.py", line 178, in run
yield from self._run_checks(self.visitors)
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/checker.py", line 166, in _run_checks
visitor.run()
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/visitors/base.py", line 140, in run
self.visit(self.tree)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ast.py", line 253, in visit
return visitor(node)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ast.py", line 261, in generic_visit
self.visit(item)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ast.py", line 253, in visit
return visitor(node)
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/visitors/ast/naming.py", line 154, in visit_ClassDef
self._validator.check_attribute_name(node)
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/visitors/ast/naming.py", line 117, in check_attribute_name
if logical.is_upper_case_name(name):
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/wemake_python_styleguide/logics/naming/logical.py", line 70, in is_upper_case_name
return any(character.isupper() for character in name)
TypeError: 'NoneType' object is not iterable
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/__main__.py", line 4, in <module>
cli.main()
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/main/cli.py", line 16, in main
app.run(argv)
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/main/application.py", line 412, in run
self._run(argv)
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/main/application.py", line 400, in _run
self.run_checks()
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/main/application.py", line 318, in run_checks
self.file_checker_manager.run()
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8_per_file_ignores.py", line 33, in run
orig_run(self)
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/checker.py", line 338, in run
self.run_parallel()
File "/Users/boger/virtualvenvs/myproject-backend-v3/lib/python3.6/site-packages/flake8/checker.py", line 302, in run_parallel
for ret in pool_map:
File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next
raise value
TypeError: 'NoneType' object is not iterable

# Fixed code
def check_attribute_name(self, node: ast.ClassDef) -> None:
    top_level_assigns = [
        sub_node for sub_node in node.body if isinstance(sub_node, ast.Assign)
    ]

    for assignment in top_level_assigns:
        for target in assignment.targets:
            if not isinstance(target, ast.Name):
                continue

            name: Optional[str] = getattr(target, "id", None)
            if name and logical.is_upper_case_name(name):
                self._error_callback(
                    naming.UpperCaseAttributeViolation(target, text=name),
                )