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

agronholm / typeguard / 254 / 4
95%
master: 95%

Build:
DEFAULT BRANCH: master
Ran 14 Aug 2020 05:36PM UTC
Files 3
Run time 1s
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

14 Aug 2020 05:34PM UTC coverage: 86.558% (-0.5%) from 87.034%
COVERALLS_PARALLEL=true TOXENV=py37

push

travis-ci-com

web-flow
Install import hook earlier during pytest initialization (#143)

The pytest plugin does not work at all in this very common scenario:

- Application/library uses a conftest.py file with pytest configuration
- This conftest.py imports application/library modules.

Even worse, no matter what is passed as the ‘--typeguard-packages=’
command line argument, no warnings or errors will be reported at all.
Typeguard will be fully silent. this this makes it seem the code is
fully correct, while in reality the code is not checked by typeguard
*at all*. Oops. 💥 🙈 😱

The problem is that the pytest plugin used the ‘pytest_sessionstart()’
hook, which triggers only after conftest.py files (or other pytest
configuration files) have been loaded already. This is too late to
install the import hook: the targeted modules may have been imported
already at this point!

This pull request fixes this problem in the following way:

- Use ‘pytest_configure()’ instead of ‘pytest_sessionstart()’, since
  the former triggers before any conftest files are loaded.

- Make it impossible to silently skip checks for packages specified on
  the command line that cannot actually be checked. In those situations,
  raise an error with all the details. Example for
  ‘--typeguard-packages=sys’:

  INTERNALERROR> RuntimeError: typeguard cannot check these packages that are already imported: sys

See also:

- https://docs.pytest.org/en/stable/reference.html#pytest.hookspec.pytest_configure
- https://docs.pytest.org/en/stable/reference.html#pytest.hookspec.pytest_sessionstart

586 of 677 relevant lines covered (86.56%)

0.87 hits per line

Source Files on job 254.4 (COVERALLS_PARALLEL=true TOXENV=py37)
  • Tree
  • List 0
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 229
  • Travis Job 254.4
  • 9673ad15 on github
  • Prev Job for COVERALLS_PARALLEL=true TOXENV=py37 on master (#252.4)
  • Next Job for COVERALLS_PARALLEL=true TOXENV=py37 on master (#255.4)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc