Skip to content

Conversation

simonw
Copy link
Owner

@simonw simonw commented May 13, 2018

  • Split out view classes from main app.py
  • Run black against resulting code to apply opinionated source code formatting
  • Run isort to re-order my imports

Refs #256

@simonw
Copy link
Owner Author

simonw commented May 13, 2018

I'm still seeing intermittent Python 3.5 failures due to dictionary ordering differences.

https://travis-ci.org/simonw/datasette/jobs/378356802

>       assert expected_facet_results == facet_results
E       AssertionError: assert {'city': [{'c...alue': 'MI'}]} == {'city': [{'co...alue': 'MI'}]}
E         Omitting 1 identical items, use -vv to show
E         Differing items:
E         {'city': [{'count': 4, 'toggle_url': '_facet=state&_facet=city&state=MI&city=Detroit', 'value': 'Detroit'}]} != {'city': [{'count': 4, 'toggle_url': 'state=MI&_facet=state&_facet=city&city=Detroit', 'value': 'Detroit'}]}
E         Use -v to get the full diff

To solve these cleanly I need to be able to run Python 3.5 on my local laptop rather than relying on Travis every time.

@simonw
Copy link
Owner Author

simonw commented May 13, 2018

I managed to get Python 3.5.0 running on my laptop using pyenv. Here's the incantation I used:

# Install pyenv using homebrew (turns out I already had it)
brew install pyenv
# Check which versions of Python I have installed
pyenv versions
# Install Python 3.5.0
pyenv install 3.5.0
# Figure out where pyenv has been installing things
pyenv root
# Check I can run my newly installed Python 3.5.0
/Users/simonw/.pyenv/versions/3.5.0/bin/python
# Use it to create a new virtualenv
/Users/simonw/.pyenv/versions/3.5.0/bin/python -mvenv venv35
source venv35/bin/activate
# Install datasette into that virtualenv
python setup.py install

@simonw
Copy link
Owner Author

simonw commented May 13, 2018

Unfortunately, running python setup.py test on my laptop using Python 3.5.0 in that virtualenv results in a flow of weird Sanic-related errors:

  File "/Users/simonw/Dropbox/Development/datasette/venv35/lib/python3.5/site-packages/sanic-0.7.0-py3.5.egg/sanic/testing.py", line 16, in _local_request
    import aiohttp
  File "/Users/simonw/Dropbox/Development/datasette/.eggs/aiohttp-2.3.2-py3.5-macosx-10.13-x86_64.egg/aiohttp/__init__.py", line 6, in <module>
    from .client import *  # noqa
  File "/Users/simonw/Dropbox/Development/datasette/.eggs/aiohttp-2.3.2-py3.5-macosx-10.13-x86_64.egg/aiohttp/client.py", line 13, in <module>
    from yarl import URL
  File "/Users/simonw/Dropbox/Development/datasette/.eggs/yarl-1.2.4-py3.5-macosx-10.13-x86_64.egg/yarl/__init__.py", line 11, in <module>
    from .quoting import _Quoter, _Unquoter
  File "/Users/simonw/Dropbox/Development/datasette/.eggs/yarl-1.2.4-py3.5-macosx-10.13-x86_64.egg/yarl/quoting.py", line 3, in <module>
    from typing import Optional, TYPE_CHECKING, cast
ImportError: cannot import name 'TYPE_CHECKING'

@simonw
Copy link
Owner Author

simonw commented May 13, 2018

readthedocs/readthedocs.org#3812 (comment) suggests Python 3.5.2 may have the fix.

Yup, that worked:

pyenv install 3.5.2
rm -rf venv35
/Users/simonw/.pyenv/versions/3.5.2/bin/python -mvenv venv35
source venv35/bin/activate
# Not sure why I need this in my local environment but I do:
pip install datasette_plugin_demos
python setup.py test

This is now giving me the same test failure locally that I am seeing in Travis.

@simonw
Copy link
Owner Author

simonw commented May 13, 2018

Running specific tests:

venv35/bin/pip install pytest beautifulsoup4 aiohttp
venv35/bin/pytest tests/test_utils.py

@simonw simonw merged commit 2b79f2b into master May 14, 2018
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.

1 participant