Skip to content
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

change how annotation formats are listed #92

Closed
NickleDave opened this issue May 30, 2021 · 2 comments · Fixed by #161
Closed

change how annotation formats are listed #92

NickleDave opened this issue May 30, 2021 · 2 comments · Fixed by #161
Assignees
Labels
ENH: enhancement New feature or request TST: testing
Projects

Comments

@NickleDave
Copy link
Collaborator

NickleDave commented May 30, 2021

rewriting tests and realizing it's not easy to test formats.show

the one unit test as written now could pass even if formats.show does not return any installed formats.
i.e. it would "pass" but actually be failing silently, because formats.show would return nothing and then we would assert that nothing is in whatever formats.show returned.

there's two separate issues here:
one is how formats.show works -- it's weird that it prints instead of returning a string or something we can work with programatically / dynamicall
that's what this issue is about -- should it return a list instead

we currently test by just capturing stdout and checking what's in the captured output, which can fail silently as just described

the other is, how do we test the output is correct?
going to open another issue for that

@NickleDave NickleDave self-assigned this May 30, 2021
@NickleDave
Copy link
Collaborator Author

another option would be to parse the pyproject.toml file in the tests to check whether specified formats are installed

this doesn't address testing user-installed formats but at least lets us have a single source of truth to test the built-in formats.

Feels slightly gross to rely on a file meant for development to test that something works "in prod" -- would rather find some other way to specify built-in formats

@NickleDave NickleDave added this to the 3.2.0 milestone Dec 2, 2021
@NickleDave NickleDave added ENH: enhancement New feature or request TST: testing labels Dec 2, 2021
@NickleDave NickleDave added this to To do in ENH Dec 2, 2021
@NickleDave NickleDave removed this from the 3.2.0 milestone Mar 20, 2022
@NickleDave NickleDave changed the title change how formats.show works -- return a list of strings? change how formats are determined Mar 27, 2022
@NickleDave
Copy link
Collaborator Author

working on 4.0 and realized that if I'm adding a formats sub-package as in #109 then I can customize the module's attributes so that they are only valid annotation format classes, by leveraging changes in #99 and #105

The basic idea is what's described here:
https://realpython.com/python37-new-features/#customization-of-module-attributes

but instead of plug-ins, I can use the abc-based interface as defined in #105 / #120 in combination with a customized __dir__ and __getattr__ to only list / return classes that are registered as sub-classes of the interface

@NickleDave NickleDave changed the title change how formats are determined change how annotation formats are listed Mar 27, 2022
NickleDave added a commit that referenced this issue Mar 27, 2022
- add formats/__init__.py with custom __dir__ and __getattr__
NickleDave added a commit that referenced this issue Mar 28, 2022
- add formats/__init__.py with custom __dir__ and __getattr__
NickleDave added a commit that referenced this issue Mar 28, 2022
- add formats/__init__.py with custom __dir__ and __getattr__
NickleDave added a commit that referenced this issue Mar 28, 2022
- add formats/__init__.py with custom __dir__ and __getattr__
NickleDave added a commit that referenced this issue Mar 30, 2022
- add formats/__init__.py with custom __dir__ and __getattr__
NickleDave added a commit that referenced this issue Apr 6, 2022
- add formats/__init__.py with custom __dir__ and __getattr__
NickleDave added a commit that referenced this issue May 1, 2022
- add formats/__init__.py with custom __dir__ and __getattr__
NickleDave added a commit that referenced this issue May 4, 2022
- add formats/__init__.py
- with `as_list` and `by_name` functions
  that use module-level constant FORMAT
  constant built dynamically at imported-time
  from the `__all__`s of `crowsetta.formats.seq`
  and `crowsetta.formats.bbox`
@NickleDave NickleDave moved this from To do to Done in ENH May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ENH: enhancement New feature or request TST: testing
Projects
ENH
Done
1 participant