10000 Transitive import of mitmproxy.version causes warning · Issue #2470 · mitmproxy/mitmproxy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Transitive import of mitmproxy.version causes warning #2470
Closed
@Kriechi

Description

@Kriechi

Since #1837, we import .script, will imports .flow, which imports .version.
This causes the following warning in pytest:

test/mitmproxy/test_version.py::test_version
  /Users/kriechi/.pyenv/versions/3.5.3/lib/python3.5/runpy.py:125: 
RuntimeWarning: 'mitmproxy.version' found in sys.modules after import of package 
'mitmproxy', but prior to execution of 'mitmproxy.version'; this may result in 
unpredictable behaviour
    warn(RuntimeWarning(msg))

-- Docs: http://doc.pytest.org/en/latest/warnings.html

Note

This next trap exists in all current versions of Python, including 3.3, and can be summed up in the following general guideline: “Never add a package directory, or any directory inside a package, directly to the Python path”.

The reason this is problematic is that every module in that directory is now potentially accessible under two different names: as a top level module (since the directory is on sys.path) and as a submodule of the package (if the higher level directory containing the package itself is also on sys.path).

Maybe using the approach described here works better?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0