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

Pin to jsonschema<4 and update config for testing on recent Python versions #385

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

terencehonles
Copy link

This combines #383 and #384 with some extra cleanup to get github actions working properly (They seem to be disabled here, but I have them now passing on my fork https://github.com/terencehonles/bravado-core/actions/runs/1358474617)

@terencehonles
Copy link
Author

From #383 (comment)

I have https://github.com/terencehonles/bravado-core/tree/fix-deprecation-warning-for-RefResolver.in_scope which fixes the deprecation warning, but when testing the change I noticed there was an error during resolving. I checked and this looks like it only affects Spec.from_dict (I skipped all tests that go down that code path and the suite passed). It doesn't appear to be straightforward to find out what changed since I'm not familiar with this package or jsonschema but it looks like it's related to python-jsonschema/jsonschema#782

Comment on lines +19 to +24
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- run: pip install tox
- run: |
tox -e py$(tr -d "." <<<"${{ matrix.python-version }}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will properly install and then test with the right Python versions

Copy link
Collaborator

@macisamuele macisamuele Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small tip: You could install tox-gh-actions to let the system call the correct tox environment. This will avoid as well the usage of shell-expansions which might be different if tests are run on different OS[1].

You can see it in use in macisamuele/language-formatters-pre-commit-hooks
Example of run here

[1] Actually github actions does support running tests on MacOs and Windows, so it might be nice to centralise testing CI into a single provider (instead of depending on appveyor)

@@ -54,7 +54,7 @@ def wrapper(value):
return value
return func(value)

return wrapper
return wrapper # type: ignore
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly the flak8 installed by pre-commit in Python2 does not support specifically ignoring types. This was # type: ignore[return-value] since wrapper is a callable but it's not being coerced to FuncType by mypy even though it should be equivalent (there's probably something more specific that's going on, but it's not particularly obvious).

pytest-benchmark[histogram]
pytest-cov
pytest<4.7 # need support for Python 2.7, see https://docs.pytest.org/en/latest/py27-py34-deprecation.html
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks for Python 3.10 will automatically be handled by pip for Python 2.7. Mypy however needs pytest<6 but that and the other mypy specific packages have been moved to requirements-typing.txt

@@ -11,7 +11,7 @@

install_requires = [
"jsonref",
"jsonschema[format]>=2.5.1",
"jsonschema[format]>=2.5.1,<4.0.0",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original point of this PR 😅

@terencehonles terencehonles force-pushed the pin-jsonschema-and-update-config branch from 53d9edb to e6a31dd Compare October 19, 2021 09:34
@terencehonles
Copy link
Author

I bumped AppVeyor to a config which actually has Python 3.9, but I still can't reproduce the Python2 error as mentioned in #383 (comment) (but now it's at least the same point version so it does seem like this is a Windows only issue)

- To report more than `<generator object ...>`
- To properly exclude `str` and `unicode` on Python3 and Python2
  respectively.
- To exclude `bool` and `bytes` which are also immutable
- To log types of the offending objects in case they need to be special
  cased in the future.
@terencehonles terencehonles force-pushed the pin-jsonschema-and-update-config branch from ab481f2 to 9f1280b Compare October 19, 2021 10:14
@terencehonles
Copy link
Author

terencehonles commented Oct 19, 2021

It looks like it was an issue with str not being called unicode on Python2, and I've updated the tests to capture that. I'm not sure why I wasn't able to reproduce locally but this run gave the answer https://ci.appveyor.com/project/sjaensch/bravado-core/builds/41198118/job/4ky1fhcrbxok3ahy .

@macisamuele macisamuele requested a review from analogue October 27, 2021 19:24
Copy link
Collaborator

@macisamuele macisamuele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes looks good to me but I'm not using the library by sometime so I'm not fully aware of what are the needs for jsonschema and pytest dependencies and what implications could have, with respect to the Yelp internal build system, the split of the dependencies from dev and typing.

Considering the above, I would delegate @analogue for the final review.

Comment on lines +19 to +24
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- run: pip install tox
- run: |
tox -e py$(tr -d "." <<<"${{ matrix.python-version }}")
Copy link
Collaborator

@macisamuele macisamuele Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small tip: You could install tox-gh-actions to let the system call the correct tox environment. This will avoid as well the usage of shell-expansions which might be different if tests are run on different OS[1].

You can see it in use in macisamuele/language-formatters-pre-commit-hooks
Example of run here

[1] Actually github actions does support running tests on MacOs and Windows, so it might be nice to centralise testing CI into a single provider (instead of depending on appveyor)

@@ -2,15 +2,33 @@
name: build
on: push
jobs:
pytest:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pytest:
tests:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants