@@ -26,10 +26,6 @@ Specifying code to be checked
26
26
27
27
Mypy lets you specify what files it should type check in several different ways.
28
28
29
- Note that if you use namespace packages (in particular, packages without
30
- ``__init__.py ``), you'll need to specify :option: `--namespace-packages <mypy
31
- --namespace-packages> `.
32
-
33
29
1. First, you can pass in paths to Python files and directories you
34
30
want to type check. For example::
35
31
@@ -322,11 +318,6 @@ this error, try:
322
318
you must run ``mypy ~/foo-project/src `` (or set the ``MYPYPATH `` to
323
319
``~/foo-project/src ``.
324
320
325
- 4. If you are using namespace packages -- packages which do not contain
326
- ``__init__.py `` files within each subfolder -- using the
327
- :option: `--namespace-packages <mypy --namespace-packages> ` command
328
- line flag.
329
-
330
321
In some rare cases, you may get the "Cannot find implementation or library
331
322
stub for module" error even when the module is installed in your system.
332
323
This can happen when the module is both missing type hints and is installed
@@ -423,10 +414,10 @@ to modules to type check.
423
414
added to mypy's module search paths.
424
415
425
416
How mypy determines fully qualified module names depends on if the options
426
- :option: `--namespace-packages <mypy --namespace-packages> ` and
417
+ :option: `--no- namespace-packages <mypy --no -namespace-packages> ` and
427
418
:option: `--explicit-package-bases <mypy --explicit-package-bases> ` are set.
428
419
429
- 1. If :option: `--namespace-packages <mypy --namespace-packages> ` is off ,
420
+ 1. If :option: `--no- namespace-packages <mypy --no- namespace-packages> ` is set ,
430
421
mypy will rely solely upon the presence of ``__init__.py[i] `` files to
431
422
determine the fully qualified module name. That is, mypy will crawl up the
432
423
directory tree for as long as it continues to find ``__init__.py `` (or
@@ -436,12 +427,13 @@ How mypy determines fully qualified module names depends on if the options
436
427
would require ``pkg/__init__.py `` and ``pkg/subpkg/__init__.py `` to exist in
437
428
order correctly associate ``mod.py `` with ``pkg.subpkg.mod ``
438
429
439
- 2. If :option: `--namespace-packages <mypy --namespace-packages> ` is on, but
440
- :option: `--explicit-package-bases <mypy --explicit-package-bases> ` is off,
441
- mypy will allow for the possibility that directories without
442
- ``__init__.py[i] `` are packages. Specifically, mypy will look at all parent
443
- directories of the file and use the location of the highest
444
- ``__init__.py[i] `` in the directory tree to determine the top-level package.
430
+ 2. The default case. If :option: `--namespace-packages <mypy
431
+ --no-namespace-packages> ` is on, but :option: `--explicit-package-bases <mypy
432
+ --explicit-package-bases> ` is off, mypy will allow for the possibility that
433
+ directories without ``__init__.py[i] `` are packages. Specifically, mypy will
434
+ look at all parent directories of the file and use the location of the
435
+ highest ``__init__.py[i] `` in the directory tree to determine the top-level
436
+ package.
445
437
446
438
For example, say your directory tree consists solely of ``pkg/__init__.py ``
447
439
and ``pkg/a/b/c/d/mod.py ``. When determining ``mod.py ``'s fully qualified
0 commit comments