-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct library interface #23
Comments
@chr7 Could you tell me which part of the library violated PEP561? Furthermore, code suggestions work correctly if I disable |
I can't tell you this, I forwarded this info from the pylance developer (see my issue there). Anyhow, I switched the language server off (was set on pylance previously): and I don't get any suggestions neither which isn't a surprise as the language server is off :-) Then I tried Jedi: I'll pass this info back to pylance, let's see what they say. |
According to the pylance developer 'Imported symbols are considered private by default. If they use the “import A as A”' They suggest to fix that. |
When I used this library, mypy said:
These errors are maybe related to this issue. With diff --git a/pathvalidate/__init__.py b/pathvalidate/__init__.py
index 63f696c..3b55b9f 100644
--- a/pathvalidate/__init__.py
+++ b/pathvalidate/__init__.py
@@ -35,3 +35,43 @@ from .error import (
ValidationError,
ValidReservedNameError,
)
+
+__all__ = (
+ "__author__",
+ "__copyright__",
+ "__email__",
+ "__license__",
+ "__version__",
+ "AbstractSanitizer",
+ "AbstractValidator",
+ "Platform",
+ "ascii_symbols",
+ "normalize_platform",
+ "replace_ansi_escape",
+ "replace_unprintable_char",
+ "unprintable_ascii_chars",
+ "validate_null_string",
+ "validate_pathtype",
+ "FileNameSanitizer",
+ "is_valid_filename",
+ "sanitize_filename",
+ "validate_filename",
+ "FilePathSanitizer",
+ "is_valid_filepath",
+ "sanitize_file_path",
+ "sanitize_filepath",
+ "validate_file_path",
+ "validate_filepath",
+ "sanitize_ltsv_label",
+ "validate_ltsv_label",
+ "replace_symbol",
+ "validate_symbol",
+ "ErrorReason",
+ "InvalidCharError",
+ "InvalidLengthError",
+ "InvalidReservedNameError",
+ "NullNameError",
+ "ReservedNameError",
+ "ValidationError",
+ "ValidReservedNameError",
+) |
@eggplants |
git clone https://github.com/eggplants/getjump
cd getjump
git checkout pathvalidate_error
pip install .
mypy getjump getjump/getjump.py:113: error: Module has no attribute "sanitize_filepath"; maybe "sanitize_file_path",
"sanitize_filename", or "validate_filepath"? [attr-defined]
pathvalidate.sanitize_filepath(
^
getjump/main.py:60: error: Module has no attribute "is_valid_filepath"; maybe "validate_filepath",
"is_valid_filename", or "validate_file_path"? [attr-defined]
if pathvalidate.is_valid_filepath(v, platform="auto"):
^
Found 2 errors in 2 files (checked 3 source files) |
Or, just: $ cat a.py
import pathvalidate
res = pathvalidate.sanitize_filepath("hello")
print(res)
$ pip install pathvalidate==2.5.0
...
$ mypy a.py --strict
a.py:3: error: Module has no attribute "sanitize_filepath"; maybe "sanitize_file_path", "sanitize_filename", or
"validate_filepath"? [attr-defined]
res = pathvalidate.sanitize_filepath("hello")
^
Found 1 error in 1 file (checked 1 source file)
$ pip uninstall pathvalidate
...
$ pip install git+https://github.com/eggplants/pathvalidate@add_all
...
$ mypy a.py --strict
Success: no issues found in 1 source file $ mypy --version
mypy 0.960 (compiled: yes)
$ python --version
Python 3.10.4
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy |
@eggplants |
pathvalidate 2.5.0
In Visual Studio Code, no suggestions are given for functions of pathvalidate, e.g. for
sanitize_filename
:I thought that this is a problem of VSC's pylance therefore I opened this issue. It was closed with the comment that this is a problem how pathvalidate does the import. To fix it, it should be done as described in PEP561 resp. library interface.
The text was updated successfully, but these errors were encountered: