Skip to content

Fix "not exported from module" error in Pyright - #51

Merged
rikhilrai merged 3 commits into
DeveloperRSquared:mainfrom
eddyg:fix-non-aliased-imported-symbols
Oct 18, 2022
Merged

rikhilrai merged 3 commits into
DeveloperRSquared:mainfrom
eddyg:fix-non-aliased-imported-symbols

Conversation

@eddyg

@eddyg eddyg commented Sep 17, 2022 •

Copy link
Copy Markdown
Contributor

Without this change, Pyright reports this error:

"CaseInsensitiveDict" is not exported from module "case_insensitive_dict"
  Import from "case_insensitive_dict.case_insensitive_dict" instead

Upstream Pyright seems to have confirmed the behavior is intended and libraries need to be explicit about which symbols are considered public. (See the linked docs in microsoft/pyright#2277)

The other alternative seems to be modifying the imports in __init__.py to have aliases, like this:

from .case_insensitive_dict import CaseInsensitiveDict as CaseInsensitiveDict
from .case_insensitive_dict import CaseInsensitiveDictJSONEncoder as CaseInsensitiveDictJSONEncoder
from .case_insensitive_dict import case_insensitive_dict_json_decoder as case_insensitive_dict_json_decoder

but that requires adding:

# pylint: disable=useless-import-alias

Let me know if you think there's a better way to address this.

Thanks!

Without this, Pyright reports this error:

"CaseInsensitiveDict" is not exported from module "case_insensitive_dict"
  Import from "case_insensitive_dict.case_insensitive_dict" instead

Upstream pyright seems to have confirmed the behavior is intended and
libraries need to be explicit about which symbols are considered public.
(See the linked docs in microsoft/pyright#2277)
@rikhilrai
rikhilrai temporarily deployed to TestPyPI October 18, 2022 08:41 Inactive
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #51 (418f2e0) into main (ad9c4b3) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main       #51   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           59        59           
  Branches         7         7           
=========================================
  Hits            59        59           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Comment thread .github/workflows/build.yml Resolved
@rikhilrai
rikhilrai temporarily deployed to TestPyPI October 18, 2022 08:45 Inactive
@rikhilrai

Copy link
Copy Markdown
Contributor

Thanks for your contribution! LGTM

@rikhilrai
rikhilrai merged commit 0e09704 into DeveloperRSquared:main Oct 18, 2022
@eddyg
eddyg deleted the fix-non-aliased-imported-symbols branch October 21, 2022 21:13

This branch was previously deployed

1 inactive deployment
TestPyPI — f3feafea Deployed Oct 18, 2022 by rikhilrai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants