Comments (8)
Hi @BeRT2me,
There's a new version of the tool out! v1.9.0 introduces two new options to the poly check
and poly libs
commands:
--strict
This option will narrow down the comparison between imports and third-party libraries. This should make false positives more rare. This option will allow libraries with -
and the corresponding imports, using _
, but not pandas and geopandas.
Usage:
poetry poly check --strict
--alias
This option will help the check and libs commands, when the difference between a library name and the import is too big. I chose to add it as a command option, to make it project-specific (and not for all projects in the workspace).
Usage:
poetry poly check --alias opencv-python=cv2
This will treat cv2
as a third-party library when running the analysis.
I hope this will help and make the commands more accurate! There will likely be more cases where the commands will fail on identifying libraries, but I think these options will cover many use cases.
The --strict
and --alias
options can be used in combination, to both rule out false positives and identifying dependencies.
from python-polylith.
Thank you for reporting @BeRT2me!
This is probably because the poly check
command couldn't see enough similarities between PIL
and pillow
and I will have a look at it. I have probably missed out the string comparison between different caps or something like that 😄
from python-polylith.
@BeRT2me I believe I have fixed this issue and just released v1.8.2
of the tool. Please let me know if this has solved your issue, and thank you again for reporting it here! ⭐
from python-polylith.
@DavidVujic This is great, thank you!
Another one I've discovered are OpenCV
packages; which can be installed as any one of:
opencv-python
opencv-contrib-python
opencv-python-headless
opencv-contrib-python-headless
And all have the import cv2
.
Also, the mpl_toolkits
import than comes with matplotlib
.
from python-polylith.
Yes, these imports are probably too different from the dependency names, and the builtin difflib that is used in the source code won't recognize them properly.
I think I will add a possibility to ignore, or to make hints, to the poly check
and poly libs
commands.
from python-polylith.
Yeah, there are an unfortunate number of libraries that don't align their name and imports.
Although using difflib is a super interesting approach, I do worry about false positives. Maybe just giving the ability to map library names to a list of known imports wouldn't be clearer - and eliminate those false positives.
Something like this in the workspace.toml
file:
[tool.polylith.known-libraries]
opencv-python = ["cv2"]
matplotlib = ["matplotlib", "mpl_toolkits"]
pillow = ["PIL"]
scikit-image = ["skimage"]
from python-polylith.
Good ideas! ⭐ I plan to work on this during next week.
from python-polylith.
Speaking of false positives, pandas
being installed falsely allowed geopandas
to be overlooked.
from python-polylith.
Related Issues (20)
- verbose output for `poetry poly sync` HOT 3
- Sync should respect --quiet flag HOT 1
- How to handle dependecies? HOT 3
- Poly diff to list changed bases/components for CI testing HOT 2
- poly diff reports changes on non-brick code
- Support for different git tag patterns (stable-*, release-* etc.) HOT 1
- PDM support HOT 1
- In-brick pyproject.toml support HOT 3
- Any example to deploy a project using docker? HOT 1
- Add support for Python 3.12 when analyzing source code (poly libs)
- poly delete HOT 1
- `tdd` theme doesn't work with `pdm` HOT 5
- adding a poly deps command
- poetry scripts break when building with --with-top-namespace HOT 8
- poetry poly create base will allow names with dashes HOT 4
- Poly sync not working properly for projects in sub-directories HOT 1
- poly info command does not list components under lower level namespaces HOT 1
- [Feature] Optionally generate `py.typed` stub file, while creating bases & components HOT 9
- Allow using `tests` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-polylith.