Repository navigation
Conversation
- query_processor.py: drop the `starargs`/`kwargs` checks on `ast.Call` (removed in Python 3.5; `*args`/`**kwargs` show up in `args` and `keywords`, which are already checked), and the `__metaclass__` attribute (ignored by Python 3) with its `code_util` import and the commented-out `add_metaclass` decorator. - tract_math/decorator.py: `csv.DictWriter.writeheader` always exists. - shell.py: `except SyntaxError as e: print(e.value)` raised AttributeError, because SyntaxError has no `value`; print the exception. `names()` translated `x_left` keys to `x.left`/`x.right` and hid `x_right`, from when side queries were stored as `x_left`. They are now stored as `x.left`, so the translation only mangled user queries whose names end in `_left`/`_right`. Return the query names unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
These are the Python 2 leftovers listed in #115:
query_processor.pyvisit_Callchecks thestarargs/kwargsattributes ofast.Call. They were removed in Python 3.5.f(*x)now shows up as anast.Starredinargs, andf(**x)as akeywordinkeywords, which the same condition already checks (len(node.keywords) == 0, and aStarredargument is rejected bygeneric_visit).query_processor.pyEvaluateQueries.__metaclass__ = DocStringInheritor: Python 3 ignores the attribute, so it has no effect.tract_math/decorator.py:hasattr(writer, 'writeheader')is always true on Python 3.shell.py:except SyntaxError as e: print(e.value)(indo_saveanddefault) would raiseAttributeError, becauseSyntaxErrorhas novalue.safe_methodthen reports it as "Uncaught exception, please contact the development team". In practicequeries_preprocessconverts syntax errors toTractQuerierSyntaxError, so this handler is a fallback, but it should not crash.shell.pynames()(used by the shell'sdircommand and tab completion): this is not a Python 2 issue but a leftover of the old query naming. Before 692ffd0, side queries were stored asx_left/x_right, andnames()showed them asx.left/x.right. Now they are stored asx.left/x.right, so this branch never matches them. It only mangled user queries whose names end in_left:c_left = 1; c_right = 2was listed asc.left,c.right, which do not exist, andc_rightwas hidden.Change
query_processor.py: drop the twostarargs/kwargslines, the__metaclass__line, thefrom .code_util import DocStringInheritorimport, and the commented-out# @add_metaclass(DocStringInheritor).tract_math/decorator.py: callwriter.writeheader()unconditionally.shell.py:print(e)forSyntaxError.names()returns the evaluated query names unchanged.No behaviour change apart from the two shell fixes: no crash on a
SyntaxError, anddir/ tab completion list the real names of queries ending in_left/_right. For dotted side queries (x.left, everything in the packaged.qryfiles)names()returns exactly what it returned before.Testing
New
tract_querier/tests/test_shell.py:names()on a shell witha.left,a.right,b,c_left,c_right;SyntaxErrorfromqueries_preprocess(monkeypatched) is printed bydefaultanddo_savewithout "Uncaught exception".Both tests fail with master's
shell.py.Called
process_outputwith a dict of lists and with a dict of scalars: the CSV/TSV header and rows are printed as before.python -m pytest -q -p no:cacheprovider tract_querier: 44 passed, 1 skipped.Merge order:
__metaclass__/code_utilimport removal is the same change as in ENH: Remove dead code from the core package #136 (ENH: remove dead and broken code #107, removescode_util/). The hunks are identical, and this PR also removes the commented-out decorator line. Whichever lands second should merge cleanly or need a trivial resolution.code_util/itself is left to ENH: Remove dead code from the core package #136.decorator.pyline overlaps ENH: Make the command-line tools usable in batch runs #138, which re-indents that block into awith f:(and keeps thehasattr). If ENH: Make the command-line tools usable in batch runs #138 lands first, the resolution is to keep itswithblock and drop thehasattr/else.visit_Callis also touched by BUG: Makesave('name')in queries mark the query for output #137 (BUG:save(...)in queries can never work #104).Closes #115
🤖 Generated with Claude Code