• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OpShin / eopsin / 439

pending completion
439

push

travis-ci-com

nielstron
New version

- bump pluthon version
- add constructor bool from int

1 of 1 new or added line in 1 file covered. (100.0%)

2782 of 3011 relevant lines covered (92.39%)

0.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.33
/eopsin/rewrite/rewrite_inject_builtin_constr.py
1
from copy import copy
1✔
2

3
from ..typed_ast import *
1✔
4
from ..util import (
1✔
5
    CompilingNodeTransformer,
6
)
7

8
"""
9
Inject constructors for the builtin types that double function as type annotation
10
"""
11

12

13
class RewriteInjectBuiltinsConstr(CompilingNodeTransformer):
1✔
14
    step = "Injecting builtin type constructors"
1✔
15

16
    def visit_Module(self, node: TypedModule) -> TypedModule:
1✔
17
        additional_assigns = []
1✔
18
        for t, tname in [
1✔
19
            (ByteStringType(), bytes.__name__),
20
            (IntegerType(), int.__name__),
21
            (StringType(), str.__name__),
22
            (BoolType(), bool.__name__),
23
        ]:
24
            typ = t.constr_type()
1✔
25
            if isinstance(typ.typ, PolymorphicFunctionType):
1✔
26
                # skip polymorphic functions
27
                continue
×
28
            additional_assigns.append(
1✔
29
                TypedAssign(
30
                    targets=[TypedName(id=tname, typ=typ, ctx=Store())],
31
                    value=RawPlutoExpr(typ=typ, expr=plt.Lambda(["_"], t.constr())),
32
                )
33
            )
34
        md = copy(node)
1✔
35
        # prepend all builtin definitions
36
        md.body = additional_assigns + node.body
1✔
37
        return md
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc