Kaydet (Commit) 30d473b1 authored tarafından Batuhan Taşkaya's avatar Batuhan Taşkaya

Descriptive error messages

üst 56ac5e69
......@@ -21,8 +21,11 @@ class PEP211Transformer(ast.NodeTransformer):
and isinstance(node.iter, ast.BinOp)
and isinstance(node.iter.op, ast.MatMult)
):
if len(node.target.elts) != 2:
raise ValueError("There is should be only 2 names to unpack.")
if len(node.target.elts) < 2:
raise ValueError(f"Not enough values to unpack (expected 2, got {len(node.target.elts)})")
elif len(node.targets.elts) > 2:
raise ValueError("Too many values to unpack (expected 2)")
a, b = node.target.elts
return ast.For(
target=a,
......
......@@ -17,6 +17,6 @@ class PEP276Transformer(ast.NodeTransformer):
def visit_For(self, node):
if isinstance(node.iter, ast.Num):
if not isinstance(node.iter.n, int):
raise TypeError("The number should be integer, not float nor other number types.")
raise TypeError("The number should be integer, not float / complex.")
node.iter = ast.Call(ast.Name("range", ast.Load()), [node.iter], [])
return node
......@@ -8,7 +8,7 @@ with open(current_dir / "README.md", encoding="utf-8") as f:
setup(
name="pepallow",
version="0.1.3",
version="0.2",
packages=find_packages(),
url="https://github.com/abstractequalsmagic/pepallow",
description = "Hack the interpreter for running rejected pep's changes.",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment