Comments (10)
Thanks for your patience!
I admittedly have never heard of mypy before. I'm familiar with Python's built-in typing. Can you give me a brief rundown of what all your proposed changes entail, perhaps with some examples?
from pyxdameraulevenshtein.
Mypy is one of the static type checkers that use the type annotations. All I did was create the pyi typing stubs which describe an interface's types. Sort of like a C header file. The pyi files are mainly for backporting types into older packages. But since none of the type-checkers do analysis of Cython code directly they are also useful for providing typing information in that case. There's two ways to distribute the pyi files. You can put them in the installed files alongside python code in the same project. The second is to upload a second package to pypi that has the same name but adds "-stubs" to the end. The type checkers can find those packages and will download them to have the type information available.
Getting setuptools to do the side by side installation of pyi files and extension modules isn't obvious. I really don't think I did it correctly. Normally you have to turn on package_data and include the files through that mechanism. That method requires a restructuring of your project into a multiple file project with some renaming, basically it needs a root directory with an __init__.py
to put the type files into (At least I think). Single file projects don't really support the side by side style.
Of course if the stub package method is used then they must be maintained separately. This package's interface seems pretty stable so it might not be that bad to do. I can send you the pyi file if you want to do it yourself. It's pretty easy to generate though.
from pyxdameraulevenshtein.
Sorry for the slow responses here!
Can you show me some examples of the changes you made? I see your fork here, but it looks to be current with the master
branch on this project. I'm really curious to see how this works in practice.
from pyxdameraulevenshtein.
from typing import Sequence, Any, List
def damerau_levenshtein_distance(seq1: Sequence[Any], seq2: Sequence[Any]) -> int: ...
def normalized_damerau_levenshtein_distance(seq1: Sequence[Any], seq2: Sequence[Any]) -> float: ...
def damerau_levenshtein_distance_seqs(seq: Sequence[Any], seqs: Sequence[Sequence[Any]]) -> List[int]: ...
def normalized_damerau_levenshtein_distance_seqs(seq: Sequence[Any], seqs: Sequence[Sequence[Any]]) -> List[float]: ...
That's pretty much the whole thing as far as code goes. The problem is I haven't really figured out how to package this file up into the project correctly. If this is made as a stub package you really just need to put this in an __init__.pyi
in it's own project with a specific file structure and upload it to pypi. There isn't much guidance for side by side installation of interface files with extension packages. Instructions for using this pyi file with a pure python project are available.
from pyxdameraulevenshtein.
Do we actually even need an interface file, though? Can we not just put it directly in pyxdameraulevenshtein.pyx? I haven't tried it myself yet, but it looks like Cython supports static type definitions. I'd need to spend time digesting this, though, and this project is unfortunately not a priority for me at the moment. I'd love a PR, though!
from pyxdameraulevenshtein.
As far as I know the Python typing system and Cython typing system are separate. Mypy et al. don't really deal with Cython types. I'll keep working on it when I get a chance and try and figure out the packaging stuff.
from pyxdameraulevenshtein.
Thanks! I look forward to seeing what you discover.
from pyxdameraulevenshtein.
Ok got to it faster than I expected. I just made a second stubs package in the same repo. So now you have to push to pypi once in the main directory, then move to type-stubs and upload from there too. I have it in my fork if you want to look at it. I'll do a pull request if this mechanism works for you.
from pyxdameraulevenshtein.
Looks very simple actually! Would you mind creating a PR?
from pyxdameraulevenshtein.
Done via #37.
from pyxdameraulevenshtein.
Related Issues (20)
- importing pyxdameraulevenshtein crashes python kernel HOT 13
- Great -> Grreat != Meat -> Meet HOT 2
- Unable to install as a setup.py dependency HOT 25
- 'ValueError: numpy.ufunc has the wrong size, try recompiling' when install pyxDamerauLevenshtein HOT 27
- would it be possible to add the limit/threshold in the Damerau Levenshtein? HOT 1
- numpy.dtype error HOT 16
- How to make edits to the source code HOT 3
- Cannot install module on Python 3.7 HOT 1
- is it possible to include a method to return a sequence of edit operations performed similar to editops in python-Levenshtein? HOT 2
- Distance is one too small if first string is longer HOT 5
- Distance between "abc", "abcde" is 2 but between "abcde", "abc" is 1 HOT 1
- Python 3.5 numpy support HOT 2
- Error Installing through Pip on Python3.7 on Linux Ubuntu 18.04 HOT 3
- Failure with numpy 1.18.4 HOT 9
- 1.6.2 tag missing on GitHub HOT 1
- ImportError: cannot import name 'damerau_levenshtein_distance_ndarray' HOT 10
- reproducing benchmark results HOT 3
- New portal
- Clarify that pyxDamerauLevenshtein calculates the restricted Damerau-Levenshtein distance HOT 3
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 pyxdameraulevenshtein.