symbex 0.3.1__tar.gz → 0.3.2__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: symbex
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Find the Python code for specified symbols
5
5
  Home-page: https://github.com/simonw/symbex
6
6
  Author: Simon Willison
@@ -132,7 +132,7 @@ cog.out(
132
132
  # File: symbex/cli.py Line: 37
133
133
  def cli(symbols, files, directories, signatures, silent)
134
134
 
135
- # File: symbex/lib.py Line: 150
135
+ # File: symbex/lib.py Line: 161
136
136
  def class_definition(class_def)
137
137
 
138
138
  # File: symbex/lib.py Line: 32
@@ -117,7 +117,7 @@ cog.out(
117
117
  # File: symbex/cli.py Line: 37
118
118
  def cli(symbols, files, directories, signatures, silent)
119
119
 
120
- # File: symbex/lib.py Line: 150
120
+ # File: symbex/lib.py Line: 161
121
121
  def class_definition(class_def)
122
122
 
123
123
  # File: symbex/lib.py Line: 32
@@ -1,7 +1,7 @@
1
1
  from setuptools import setup
2
2
  import os
3
3
 
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
 
6
6
 
7
7
  def get_long_description():
@@ -109,7 +109,14 @@ def function_definition(function_node: AST):
109
109
  # if defaults has 2 and args has 3 then those
110
110
  # defaults correspond to the last two args
111
111
  defaults = [None] * (len(all_args) - len(function_node.args.defaults))
112
- defaults.extend(literal_eval(default) for default in function_node.args.defaults)
112
+ for default in function_node.args.defaults:
113
+ try:
114
+ value = literal_eval(default)
115
+ if isinstance(value, str):
116
+ value = f'"{value}"'
117
+ except ValueError:
118
+ value = getattr(default, "id", "...")
119
+ defaults.append(value)
113
120
 
114
121
  arguments = []
115
122
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: symbex
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Find the Python code for specified symbols
5
5
  Home-page: https://github.com/simonw/symbex
6
6
  Author: Simon Willison
@@ -132,7 +132,7 @@ cog.out(
132
132
  # File: symbex/cli.py Line: 37
133
133
  def cli(symbols, files, directories, signatures, silent)
134
134
 
135
- # File: symbex/lib.py Line: 150
135
+ # File: symbex/lib.py Line: 161
136
136
  def class_definition(class_def)
137
137
 
138
138
  # File: symbex/lib.py Line: 32
@@ -11,7 +11,7 @@ def directory_full_of_code(tmpdir):
11
11
  for path, content in (
12
12
  ("foo.py", "def foo1():\n pass\n\n@decorated\ndef foo2():\n pass\n\n"),
13
13
  ("bar.py", "class BarClass:\n pass\n\n"),
14
- ("nested/baz.py", "def baz():\n pass\n\n"),
14
+ ("nested/baz.py", 'def baz(delimiter=", ", type=str):\n pass\n\n'),
15
15
  ("nested/error.py", "def baz_error()" + "bug:\n pass\n\n"),
16
16
  (
17
17
  "methods.py",
@@ -60,7 +60,7 @@ def directory_full_of_code(tmpdir):
60
60
  ),
61
61
  (
62
62
  ["baz", "--silent"],
63
- "# File: nested/baz.py Line: 1\ndef baz():\n pass\n\n",
63
+ '# File: nested/baz.py Line: 1\ndef baz(delimiter=", ", type=str):\n pass\n\n',
64
64
  ),
65
65
  (
66
66
  ["async_func", "--silent"],
@@ -69,12 +69,12 @@ def directory_full_of_code(tmpdir):
69
69
  # The -f option
70
70
  (
71
71
  ["baz", "-f", "nested/baz.py", "--silent"],
72
- "# File: nested/baz.py Line: 1\ndef baz():\n pass\n\n",
72
+ '# File: nested/baz.py Line: 1\ndef baz(delimiter=", ", type=str):\n pass\n\n',
73
73
  ),
74
74
  # The -d option
75
75
  (
76
76
  ["baz", "-d", "nested", "--silent"],
77
- "# File: nested/baz.py Line: 1\ndef baz():\n pass\n\n",
77
+ '# File: nested/baz.py Line: 1\ndef baz(delimiter=", ", type=str):\n pass\n\n',
78
78
  ),
79
79
  # Classes
80
80
  (
@@ -144,7 +144,10 @@ def test_fixture(directory_full_of_code, monkeypatch, args, expected):
144
144
  "def foo2()",
145
145
  ),
146
146
  (["BarClass", "--silent"], "# File: bar.py Line: 1\n" "class BarClass"),
147
- (["baz", "--silent"], ("# File: nested/baz.py Line: 1\n" "def baz()")),
147
+ (
148
+ ["baz", "--silent"],
149
+ ("# File: nested/baz.py Line: 1\n" 'def baz(delimiter=", ", type=str)'),
150
+ ),
148
151
  ),
149
152
  )
150
153
  def test_symbex_symbols(directory_full_of_code, monkeypatch, args, expected):
@@ -162,8 +165,11 @@ def test_errors(directory_full_of_code, monkeypatch):
162
165
  monkeypatch.chdir(directory_full_of_code)
163
166
  result = runner.invoke(cli, ["baz"], catch_exceptions=False)
164
167
  assert result.exit_code == 0
165
- assert result.stdout == (
166
- "# File: nested/baz.py Line: 1\n" "def baz():\n" " pass\n\n"
168
+ expected = (
169
+ "# File: nested/baz.py Line: 1\n"
170
+ 'def baz(delimiter=", ", type=str):\n'
171
+ " pass\n\n"
167
172
  )
173
+ assert result.stdout == expected
168
174
  # This differs between different Python versions
169
175
  assert result.stderr.startswith("# Syntax error in nested/error.py:")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes