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

PyCQA / pylint / 860
92%
main: 95%

Build:
Build:
LAST BUILD BRANCH: maintenance/2.15.x
DEFAULT BRANCH: main
Ran 02 Mar 2018 09:13AM UTC
Jobs 4
Files 57
Run time 11min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
860

push

travis-ci

Claudiu Popa
Add type-specific nodes_of_class

nodes_of_class is a very flexible method, which is great for use in
client code (e.g. Pylint). However, that flexibility requires a great
deal of runtime type checking:

    def nodes_of_class(self, klass, skip_klass=None):
        if isinstance(self, klass):
            yield self

        if skip_klass is None:
            for child_node in self.get_children():
                for matching in child_node.nodes_of_class(klass, skip_klass):
                    yield matching

            return

        for child_node in self.get_children():
            if isinstance(child_node, skip_klass):
                continue
            for matching in child_node.nodes_of_class(klass, skip_klass):
                yield matching

First, the node has to check its own type to see whether it's of the
desired class. Then the skip_klass flag has to be checked to see
whether anything needs to be skipped. If so, the type of every yielded
node has to be check to see if it should be skipped.

This is fine for calling code whose arguments can't be known in
advance ("Give me all the Assign and ClassDef nodes, but skip all the
BinOps, YieldFroms, and Globals."), but in Astroid itself, every call
to this function can be known in advance. There's no need to do any
type checking if all the nodes know how to respond to certain
requests. Take get_assign_nodes for example. The Assign nodes know
that they should yield themselves and then yield their Assign
children. Other nodes know in advance that they aren't Assign nodes,
so they don't need to check their own type, just immediately yield
their Assign children.

Overly specific functions like get_yield_nodes_skip_lambdas certainly
aren't very elegant, but the tradeoff is to take advantage of knowing
how the library code works to improve speed.

0 of 7555 relevant lines covered (0.0%)

0.0 hits per line

Jobs
ID Job ID Ran Files Coverage
1 860.1 (TOXENV=py34) 02 Mar 2018 09:15AM UTC 0
0.0
Travis Job 860.1
2 860.2 (TOXENV=py35) 02 Mar 2018 09:13AM UTC 0
0.0
Travis Job 860.2
4 860.4 (TOXENV=py36) 02 Mar 2018 09:25AM UTC 0
0.0
Travis Job 860.4
5 860.5 (TOXENV=py37) 02 Mar 2018 09:25AM UTC 0
0.0
Travis Job 860.5
Source Files on build 860
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #860
  • 9b5aa979 on github
  • Prev Build on master (#859)
  • Next Build on master (#1833)
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

© 2026 Coveralls, Inc