Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
fix: Logging a warning for missing AST statements instead of throwing…
Browse files Browse the repository at this point in the history
… exception. Fix #6
  • Loading branch information
beneboy committed Dec 17, 2019
1 parent 09c018f commit b8a286c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stencila/pyla/code_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Handles parsing of CodeChunks to extract their properties and information about variables and functions used/defined.
"""
import ast
import logging
import traceback
import typing

Expand All @@ -11,6 +12,8 @@
ImportsType = typing.List[typing.Union[str, SoftwareSourceCode]]
OptionalStringList = typing.Optional[typing.List[str]]

LOGGER = logging.getLogger(__name__)
LOGGER.addHandler(logging.NullHandler())

# pylint: disable=R0902
class CodeChunkParseResult:
Expand Down Expand Up @@ -412,7 +415,7 @@ def parse_statement(self,
ast.ClassDef, ast.Num, ast.Str, ast.Pass, ast.NameConstant, ast.Bytes, ast.Break, ast.Continue)):
pass
else:
raise TypeError('Unrecognized statement: {}'.format(statement))
LOGGER.warning('Unrecognized statement %s', statement)

def _parse_import(self, statement: typing.Union[ast.ImportFrom, ast.Import]) -> None:
"""
Expand Down

0 comments on commit b8a286c

Please sign in to comment.