| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Should be good to go now. Might need to iterate a bit on the pyenv caching – it's better to cache the artefacts in .pyenv than the build cache. |
Sorry, something went wrong.
| with open("tmp/index.html"): | ||
| print("great") | ||
|
|
||
| with A() as X: |
There was a problem hiding this comment.
what the what?
Sorry, something went wrong.
|
Got a fix coming in a bit. This is all prep for #8. |
Sorry, something went wrong.
| ]); | ||
| } | ||
|
|
||
| case "withitem": { |
There was a problem hiding this comment.
no such node type
Sorry, something went wrong.
|
|
||
| const n = path.getValue(); | ||
| if (n.body.length === 1 && n.body[0].ast_type === "With") { | ||
| path.each(p => { |
There was a problem hiding this comment.
is this idiomatic? i couldn't find a better way but i might not have looked hard enough
the idea is that body is an array, but in this case it's of length 1, so we want to call something on it
Sorry, something went wrong.
There was a problem hiding this comment.
Maybe:
return concat(
path.map(
p => printPython2With(p, items, print),
"body"
)
)
Sorry, something went wrong.
There was a problem hiding this comment.
Oops. Now I feel embarrassed for not thinking of that. Thanks!
Sorry, something went wrong.
| : printPython2With(path, [], print); // Python 2 | ||
| } | ||
|
|
||
| case "withitem": { |
There was a problem hiding this comment.
never mind
Sorry, something went wrong.
| env: | ||
| global: | ||
| - PYTHON_VERSIONS="2.7.11 3.6.3" | ||
| matrix: |
There was a problem hiding this comment.
this runs a separate build for each version of python under test, rather than a single build that tests both pythons
Sorry, something went wrong.
|
|
||
| base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
|
||
| sys.path.insert(0, os.path.join(base_dir, 'vendor')) |
There was a problem hiding this comment.
I've seen this pattern used elsewhere for CLI-y things where messing with the global Python path isn't a problem. I like that this hides the vendoring details from the caller.
It's also good to split out vendored things from things that are patched from upstream.
Sorry, something went wrong.
| if (error) { | ||
| throw new Error(error); | ||
| function parse(text) { | ||
| const executionResult = spawnSync("python", ["-m", "prettier.parser"], { |
There was a problem hiding this comment.
you get a bit more flexibility when you run something as a module... you can do things like relative imports, which are sorta handy
Sorry, something went wrong.
| @@ -1 +1 @@ | |||
| run_spec(__dirname, ["python"], { pythonVersion: "3" }); | |||
| run_spec(__dirname, ["python"], ">=3.6"); | |||
There was a problem hiding this comment.
might as well... python 3.5 still sees some use, since it's what some of the active ubuntu LTS versions still ship
Sorry, something went wrong.
There was a problem hiding this comment.
Elasticbeanstalk (AWS) is stuck to python 3.4, I'd keep support for 3.4+ if possible
Sorry, something went wrong.
| const output = prettyprint(source, path, mergedOptions); | ||
| test(`${filename} - ${mergedOptions.parser}-verify`, () => { | ||
| expect(raw(source + "~".repeat(80) + "\n" + output)).toMatchSnapshot( | ||
| expect(raw(source + "~".repeat(79) + "\n" + output)).toMatchSnapshot( |
There was a problem hiding this comment.
this was a silly change, but 79 makes more sense than 80 if you know it's going to be python code formatted to 79 chars
Sorry, something went wrong.
There was a problem hiding this comment.
Should do .repeat(mergedOptions.printWidth). FYI I'd like to eventually share this file from Prettier as a package.
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed.
Merging these would be cool. We'd still have to wrap it for Python to do the version thing, though.
Sorry, something went wrong.
| with open("tmp/index.html"): | ||
| print("great") | ||
|
|
||
| with A() as X: |
There was a problem hiding this comment.
and as a result of the build changes, we now automatically flag unnecessary 2/3 inconsistencies like these
(this was the only one)
Sorry, something went wrong.
| function parse(text) { | ||
| const executionResult = spawnSync("python", ["-m", "prettier.parser"], { | ||
| env: { | ||
| PATH: process.env.PATH, |
There was a problem hiding this comment.
this is so the virtualenv python gets picked up. i don't think we need anything else from env here
Sorry, something went wrong.
| - yarn install | ||
| before_install: | ||
| - export PYTHON_BUILD_CACHE_PATH="/home/travis/.pyenv_cache" | ||
| - curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash |
There was a problem hiding this comment.
Turns out pyenv is already available on Travis (even when the language is node_js), and they have a decent selection of versions already installed.
Sorry, something went wrong.
| - 8 | ||
| - 9 | ||
| env: | ||
| - PYTHON_VERSION=2.7.14 |
There was a problem hiding this comment.
2.7.14 is the current release here; 2.7.11 is two years old and hasn't been current for a year and a half
Sorry, something went wrong.
| 'start': token.startpos, | ||
| 'end': token.endpos, | ||
| } | ||
| for token in atok.tokens if token.type == tokenize.COMMENT |
There was a problem hiding this comment.
resolves https://github.com/prettier/prettier-python/pull/9/files#r158746577 and correspondingly fixes comment handling in python 2
Sorry, something went wrong.
|
Any updates here? This PR is unfortunately a mix of a few different things, but I think it sets a lot of pieces in place for further work:
I'd like to use this as a starting point for leveraging existing Python tools to make it easier to handle edge cases here. |
Sorry, something went wrong.
| ) { | ||
| if (!semver.satisfies(PYTHON_VERSION, versionRange)) { | ||
| // Skip each test here with the snapshot name below to avoid obsolete | ||
| // snapshot failures. |
There was a problem hiding this comment.
But they are obsolete, right?
Sorry, something went wrong.
There was a problem hiding this comment.
I tried to clarify the comment a bit.
The idea is that we run the same tests for both Python 2 and Python 3. However, some of these tests can't be run for Python 2.
For those tests, we skip them when the system Python is Python 2 – but if we don't explicitly skip them like this, then they throw off "obsolete snapshot" failures.
Those failures would be correct if we were only dealing with Python 2, but it's more that they're not pertinent to the test suite as currently run.
Sorry, something went wrong.
|
Any updates here? I can rebase this if we think this is the right approach. |
Sorry, something went wrong.
|
I'll try to have a good look this weekend, thanks, and sorry for the delay :) |
Sorry, something went wrong.
|
I don't think I'm going to have time to pick up on this again any time soon. Can someone else take over this PR? |
Sorry, something went wrong.
|
Not planning on doing further work on this. We've switched to Black for the time being anyway. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Not quite ready to go yet. Need to fix tests.