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

agronholm / typeguard / 254
95%

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

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

5 of 11 new or added lines in 1 file covered. (45.45%)

598 of 676 relevant lines covered (88.46%)

3.46 hits per line

Jobs
ID Job ID Ran Files Coverage
2 254.2 (COVERALLS_PARALLEL=true TOXENV=py35) 14 Aug 2020 05:36PM UTC 0
85.67
Travis Job 254.2
3 254.3 (COVERALLS_PARALLEL=true TOXENV=py36) 14 Aug 2020 05:36PM UTC 0
87.44
Travis Job 254.3
4 254.4 (COVERALLS_PARALLEL=true TOXENV=py37) 14 Aug 2020 05:36PM UTC 0
86.56
Travis Job 254.4
5 254.5 (COVERALLS_PARALLEL=true TOXENV=py38) 14 Aug 2020 05:37PM UTC 0
86.41
Travis Job 254.5
Source Files on build 254
Detailed source file information is not available for this build.
  • Back to Repo
  • Build #254
  • 9673ad15 on github
  • Prev Build on master (#252)
  • Next Build on master (#255)
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