-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
custom extension attributes' introspection and usability #3707
Comments
I did some digging. I think tab-completion could be made to work if you define a custom |
Thanks for looking into this – I was hoping that something like this would be possible! Having tab completion for custom attributes would definitely be really nice. If you have time to experiment with this and want to submit a PR, that'd be cool. Otherwise I'm also happy to take a look at this for a future release 🙂 |
@bdewilde See #3729 for my first draft on this – I've only tested this in our test suite and in my Ipython shell and it works as expected for me 😃 What do you think? Making textacy expose custom attributes and methods sounds like a really cool idea btw, so I'm excited to see this come together. |
@ines , you are such a rockstar. Sorry I didn't get to this — have been hacking on textacy for the past couple days 😅 — but glad to see you did what I'd imagined in As for the docstring change, it might be worth prepending a little note to the original docstring re: the initial Thanks again for the prompt turnaround! |
@bdewilde Yeah, I think you're right – more details definitely won't hurt. I just updated my branch accordingly. If it all works as expected for you, I'll merge this. (Release has to wait until v2.1.5, though, since we've already triggered the wheel builds for v2.1.4 😅) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature description
Hello! I'm exploring ways to better leverage
spacy
's increased customizability intextacy
, and one option is to replace thetextacy.Doc
wrapper with a collection of custom extension attributes added to the regularspacy.Doc
. Seems doable so far, but I've run into a couple significant usability issues:doc._.
+ TAB only showsdoc_extensions
,get
,has
,mutable_types
(which maybe we don't need to see?),set
,span_extensions
, andtoken_extensions
. I don't know if there's actually any way to store the extensions in a tab-completable way, but it would be super helpful to users.functools.partial
. This is a known problem, but possible solutions are controversial:Together, these issues makes it harder for users to 1. know what extensions are available to them, and 2. understand what they do and how to use them. The existing functionality —
Doc.has_extension()
andDoc.get_extension()
, or justdoc._.doc_extensions
— work well for code, but their outputs aren't human-friendly:I don't know if there are any good solutions to these issues, or if you'd want to take them on, but I think they'd make extension attributes a great deal easier to work with.
The text was updated successfully, but these errors were encountered: