Skip to content

Commit

Permalink
Fix spelling and texting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed May 2, 2017
1 parent 99aed44 commit 8f8bf37
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 30 deletions.
41 changes: 19 additions & 22 deletions src/RestrictedPython/transformer.py
Expand Up @@ -705,9 +705,9 @@ def visit_BitAnd(self, node):
return self.node_contents_visit(node)

def visit_MatMult(self, node):
"""Matrix Multiplication should not be allowed.
"""Matrix multiplication (`@`) is currently not allowed.
Matrix Multiplication (@) is a Python 3.5+ Feature.
Matrix multiplication is a Python 3.5+ feature.
"""
self.not_allowed(node)

Expand Down Expand Up @@ -1155,18 +1155,18 @@ def visit_Continue(self, node):
return self.node_contents_visit(node)

def visit_Try(self, node):
"""Allow `Try` without restrictions.
"""Allow `try` without restrictions.
This is Python 3 only, Python 2 uses TryExcept.
"""
return self.node_contents_visit(node)

def visit_TryFinally(self, node):
"""Allow Try-Finally without restrictions."""
"""Allow `try ... finally` without restrictions."""
return self.node_contents_visit(node)

def visit_TryExcept(self, node):
"""Allow `Try-Except` without restrictions."""
"""Allow `try ... except` without restrictions."""
return self.node_contents_visit(node)

def visit_ExceptHandler(self, node):
Expand Down Expand Up @@ -1207,7 +1207,7 @@ def visit_ExceptHandler(self, node):
return node

def visit_With(self, node):
"""Protect tuple unpacking on with statements. """
"""Protect tuple unpacking on with statements."""
node = self.node_contents_visit(node)

if IS_PY2:
Expand All @@ -1227,18 +1227,13 @@ def visit_With(self, node):
return node

def visit_withitem(self, node):
"""Allow usage of `with` statements (context managers)
without restrictions."""
"""Allow `with` statements (context managers) without restrictions."""
return self.node_contents_visit(node)

# Function and class definitions

def visit_FunctionDef(self, node):
"""Check a function defintion.
Checks the name of the function and the arguments.
"""

"""Allow function definitions (`def`) with some restrictions."""
self.check_name(node, node.name)
self.check_function_argument_names(node)

Expand Down Expand Up @@ -1267,7 +1262,7 @@ def visit_FunctionDef(self, node):
return node

def visit_Lambda(self, node):
"""Check a lambda definition."""
"""Allow lambda with some restrictions."""
self.check_function_argument_names(node)

node = self.node_contents_visit(node)
Expand Down Expand Up @@ -1337,12 +1332,14 @@ def visit_YieldFrom(self, node):
self.not_allowed(node)

def visit_Global(self, node):
"""Make `global` statements allowed."""
"""Allow `global` statements without restrictions."""
return self.node_contents_visit(node)

def visit_Nonlocal(self, node):
"""Deny `nonlocal` statements.
This statement was introduced in Python 3."""
This statement was introduced in Python 3.
"""
# TODO: Review if we want to allow it later
self.not_allowed(node)

Expand All @@ -1352,7 +1349,7 @@ def visit_ClassDef(self, node):
return self.node_contents_visit(node)

def visit_Module(self, node):
"""Adds the print_collector (only if print is used) at the top."""
"""Add the print_collector (only if print is used) at the top."""
node = self.node_contents_visit(node)

# Inject the print collector after 'from __future__ import ....'
Expand All @@ -1368,23 +1365,23 @@ def visit_Module(self, node):
return node

def visit_Param(self, node):
"""Allow Param without restrictions."""
"""Allow parameters without restrictions."""
return self.node_contents_visit(node)

# Async und await

def visit_AsyncFunctionDef(self, node):
"""All async functions are denied by default."""
"""Deny async functions."""
self.not_allowed(node)

def visit_Await(self, node):
"""All async functionality are denied by default."""
"""Deny async functionality."""
self.not_allowed(node)

def visit_AsyncFor(self, node):
"""All async functionality are denied by default."""
"""Deny async functionality."""
self.not_allowed(node)

def visit_AsyncWith(self, node):
"""All async functionality are denied by default."""
"""Deny async functionality."""
self.not_allowed(node)
11 changes: 5 additions & 6 deletions tests/transformer/test_async.py
Expand Up @@ -33,15 +33,14 @@ def test_async_def(c_exec):
assert result.code is None


# special efford to test await, async for and async with


class RestrictingAsyncNodeTransformer(RestrictingNodeTransformer):
"""Transformer which allows `async def` for the tests."""

def visit_AsyncFunctionDef(self, node):
"""
AsyncFunctionDef needs to be allowed for await,
async for and async with
"""Allow `async def`.
This is needed to get the function body to be parsed thus allowing
to catch `await`, `async for` and `async with`.
"""
return self.node_contents_visit(node)

Expand Down
2 changes: 1 addition & 1 deletion tests/transformer/test_global_local.py
Expand Up @@ -34,7 +34,7 @@ def inside():

@pytest.mark.skipif(
not IS_PY3,
reason="Nonlocal Statement was introducted on Python 3.0.")
reason="The `nonlocal` statement was introduced in Python 3.0.")
@pytest.mark.parametrize(*c_exec)
def test_Nonlocal(c_exec):
result = c_exec(NONLOCAL_EXAMPLE)
Expand Down
2 changes: 1 addition & 1 deletion tests/transformer/test_yield.py
Expand Up @@ -34,7 +34,7 @@ def get_json(client, url):

@pytest.mark.skipif(
not IS_PY3,
reason="yield from statement was first introduced in Python 3.3")
reason="`yield from` statement was first introduced in Python 3.3")
@pytest.mark.parametrize(*c_exec)
def test_yield_from(c_exec):
result = c_exec(YIELD_FORM_EXAMPLE)
Expand Down

0 comments on commit 8f8bf37

Please sign in to comment.