Giter Site home page Giter Site logo

Add type declarations about python-itoolkit HOT 17 OPEN

ibm avatar ibm commented on May 29, 2024
Add type declarations

from python-itoolkit.

Comments (17)

kadler avatar kadler commented on May 29, 2024 1

IIRC, you need pytest-cov installed. Been a while, but IIRC you can use something like poetry run python -m pytest tests since Poetry manages the venvs for you.

from python-itoolkit.

kadler avatar kadler commented on May 29, 2024 1

@jwoehr feel free to work on it if you like!

from python-itoolkit.

kadler avatar kadler commented on May 29, 2024 1

There might be a way to do this with pure pip nowadays since some recent PEPs, but I'm not sure on that process.

from python-itoolkit.

jkyeung avatar jkyeung commented on May 29, 2024

If you or active volunteers (I don't count myself as active) really want this, I won't object, but I won't be a fan.

I am in the camp that has always been and will always remain against in-line type annotations in Python. I think they really destroy the readability of the language, and we don't even get type enforcement or static-typing speed out of the deal. (Unlike many controversial PEPs, PEP 484 doesn't even mention the opposition, but it was vociferous on the python-dev list.)

I would be fully supportive of comment-based (or stub file) type annotations. I think the requirement for Python 3.8 or typed-ast isn't particularly onerous, especially given that it would only be imposed on people who are already willing, able, and invested in setting up and using Sphinx.

from python-itoolkit.

kadler avatar kadler commented on May 29, 2024

Thanks for the input, @jkyeung. I'm very new to type hints, so I'm not sure the approach that I'd want to take just yet.

The biggest concern I had with Python 3.8 / typed-ast was whether that was supported by readthedocs.io, since that's where the documentation is hosted. I agree that setting up a Python 3.8 environment to build docs is not all that onerous, especially since very few people would be doing so.

from python-itoolkit.

jwoehr avatar jwoehr commented on May 29, 2024

Python 2 is no longer an issue, correct? Expired budgie.

from python-itoolkit.

kadler avatar kadler commented on May 29, 2024

Yeah, the current development release (2.0.0-dev) is Python 3.6+

from python-itoolkit.

kadler avatar kadler commented on May 29, 2024

The v1 branch still "supports" Python 2, but I don't anticipate many changes there.

from python-itoolkit.

jwoehr avatar jwoehr commented on May 29, 2024

I support the plan to add type annotation.
I don't currently have time to do that work, but I can help review it.
Or possibly later this year I may have time to work on it.

from python-itoolkit.

jwoehr avatar jwoehr commented on May 29, 2024

@kadler is anyone working on this?
@alanseiden and I were chatting on this today and I forked and converted a file.
Should I proceed thru the tree?

from python-itoolkit.

jwoehr avatar jwoehr commented on May 29, 2024

Trying to run tests but get error:

$ python -m pytest tests
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: --cov=itoolkit
 inifile: /home/jwoehr/work/python-itoolkit/setup.cfg
 rootdir: /home/jwoehr/work/python-itoolkit

Any tips?

from python-itoolkit.

jwoehr avatar jwoehr commented on May 29, 2024

Thanks, that helps. Doing better now, 87 passed, but 16 fail with an error of the form:

_________________ ERROR at setup of test_idb2call_with_ibm_db __________________
file /home/jwoehr/work/python-itoolkit/tests/test_unit_idb2call.py, line 41
  def test_idb2call_with_ibm_db(mocker, database_callproc):
E       fixture 'mocker' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, cov, database, database_callproc, database_close_exception, database_execute, doctest_namespace, monkeypatch, no_cover, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory, transport
>       use 'pytest --fixtures [testpath]' for help on them.

/home/jwoehr/work/python-itoolkit/tests/test_unit_idb2call.py:41

mocker is installed

from python-itoolkit.

kadler avatar kadler commented on May 29, 2024

Is it installed in poetry's venv? (eg. poetry run pip env)

from python-itoolkit.

jwoehr avatar jwoehr commented on May 29, 2024
(test_venv) jwoehr@pop-os:~/work/python-itoolkit$ poetry run pip env
ERROR: unknown command "env"
(test_venv) jwoehr@pop-os:~/work/python-itoolkit$ poetry run pip list --local
Package        Version
-------------- ----------
coverage       7.2.7
exceptiongroup 1.1.1
iniconfig      2.0.0
itoolkit       2.0.0.dev0
mock           5.0.2
packaging      23.1
pip            23.1.2
pluggy         1.2.0
pytest         7.4.0
pytest-cov     4.1.0
PyYAML         6.0
setuptools     59.6.0
tomli          2.0.1
wheel          0.40.0

from python-itoolkit.

kadler avatar kadler commented on May 29, 2024

Sorry, I gave the wrong command but you figured out what I meant.

Hmm, looks at the error message closer it looks like test_idb2call_with_ibm_db is taking a fixture called "mocker". Seems to be provided by pytest-mock, which is not installed in your venv. It's listed in the dev-dependencies in pyproject.toml, though. Seems like they changed things since Poetry 1.2, which uses dependency groups instead now but should still be backward compatible.

Maybe try poetry install --with dev?

from python-itoolkit.

kadler avatar kadler commented on May 29, 2024

I got it set up on my new system. Here's what I did:

from python-itoolkit.

jwoehr avatar jwoehr commented on May 29, 2024

Phew. Got that to work. Side note: one must deactivate the venv one already created for poetry install to work.

--------------------------------------------------------
TOTAL                                  700    247    65%

======================= 103 passed, 2 warnings in 0.33s ========================

from python-itoolkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.