symbex 1.3__tar.gz → 1.3.1__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: 1.3
3
+ Version: 1.3.1
4
4
  Summary: Find the Python code for specified symbols
5
5
  Home-page: https://github.com/simonw/symbex
6
6
  Author: Simon Willison
@@ -199,40 +199,40 @@ cog.out(
199
199
  ]]] -->
200
200
  ```python
201
201
  # File: symbex/lib.py Line: 107
202
- def function_definition(function_node: AST)
202
+ def function_definition(function_node: AST):
203
203
 
204
204
  # File: symbex/lib.py Line: 13
205
- def find_symbol_nodes(code: str, filename: str, symbols: Iterable[str]) -> List[Tuple[(AST, Optional[str])]]
205
+ def find_symbol_nodes(code: str, filename: str, symbols: Iterable[str]) -> List[Tuple[(AST, Optional[str])]]:
206
206
 
207
207
  # File: symbex/lib.py Line: 175
208
- def class_definition(class_def)
208
+ def class_definition(class_def):
209
209
 
210
210
  # File: symbex/lib.py Line: 209
211
- def annotation_definition(annotation: AST) -> str
211
+ def annotation_definition(annotation: AST) -> str:
212
212
 
213
213
  # File: symbex/lib.py Line: 227
214
- def read_file(path)
214
+ def read_file(path):
215
215
 
216
216
  # File: symbex/lib.py Line: 253
217
- class TypeSummary
217
+ class TypeSummary:
218
218
 
219
219
  # File: symbex/lib.py Line: 258
220
- def type_summary(node: AST) -> Optional[TypeSummary]
220
+ def type_summary(node: AST) -> Optional[TypeSummary]:
221
221
 
222
222
  # File: symbex/lib.py Line: 304
223
- def quoted_string(s)
223
+ def quoted_string(s):
224
224
 
225
225
  # File: symbex/lib.py Line: 315
226
- def import_line_for_function(function_name: str, filepath: str, possible_root_dirs: List[str]) -> str
226
+ def import_line_for_function(function_name: str, filepath: str, possible_root_dirs: List[str]) -> str:
227
227
 
228
228
  # File: symbex/lib.py Line: 37
229
- def code_for_node(code: str, node: AST, class_name: str, signatures: bool, docstrings: bool) -> Tuple[(str, int)]
229
+ def code_for_node(code: str, node: AST, class_name: str, signatures: bool, docstrings: bool) -> Tuple[(str, int)]:
230
230
 
231
231
  # File: symbex/lib.py Line: 71
232
- def add_docstring(definition: str, node: AST, docstrings: bool, is_method: bool) -> str
232
+ def add_docstring(definition: str, node: AST, docstrings: bool, is_method: bool) -> str:
233
233
 
234
234
  # File: symbex/lib.py Line: 82
235
- def match(name: str, symbols: Iterable[str]) -> bool
235
+ def match(name: str, symbols: Iterable[str]) -> bool:
236
236
  ```
237
237
  <!-- [[[end]]] -->
238
238
  This can be combined with other options, or you can run `symbex -s` to see every symbol in the current directory and its subdirectories.
@@ -254,7 +254,7 @@ cog.out(
254
254
  ```python
255
255
  # File: symbex/lib.py Line: 82
256
256
  # from symbex.lib import match
257
- def match(name: str, symbols: Iterable[str]) -> bool
257
+ def match(name: str, symbols: Iterable[str]) -> bool:
258
258
  ```
259
259
  <!-- [[[end]]] -->
260
260
  To suppress the `# File: ...` comments, use `--no-file` or `-n`.
@@ -274,7 +274,7 @@ cog.out(
274
274
  ]]] -->
275
275
  ```python
276
276
  # from symbex.lib import match
277
- def match(name: str, symbols: Iterable[str]) -> bool
277
+ def match(name: str, symbols: Iterable[str]) -> bool:
278
278
  ```
279
279
  <!-- [[[end]]] -->
280
280
 
@@ -291,7 +291,7 @@ cog.out(
291
291
  ]]] -->
292
292
  ```python
293
293
  # File: symbex/lib.py Line: 82
294
- def match(name: str, symbols: Iterable[str]) -> bool
294
+ def match(name: str, symbols: Iterable[str]) -> bool:
295
295
  "Returns True if name matches any of the symbols, resolving wildcards"
296
296
  ```
297
297
  <!-- [[[end]]] -->
@@ -184,40 +184,40 @@ cog.out(
184
184
  ]]] -->
185
185
  ```python
186
186
  # File: symbex/lib.py Line: 107
187
- def function_definition(function_node: AST)
187
+ def function_definition(function_node: AST):
188
188
 
189
189
  # File: symbex/lib.py Line: 13
190
- def find_symbol_nodes(code: str, filename: str, symbols: Iterable[str]) -> List[Tuple[(AST, Optional[str])]]
190
+ def find_symbol_nodes(code: str, filename: str, symbols: Iterable[str]) -> List[Tuple[(AST, Optional[str])]]:
191
191
 
192
192
  # File: symbex/lib.py Line: 175
193
- def class_definition(class_def)
193
+ def class_definition(class_def):
194
194
 
195
195
  # File: symbex/lib.py Line: 209
196
- def annotation_definition(annotation: AST) -> str
196
+ def annotation_definition(annotation: AST) -> str:
197
197
 
198
198
  # File: symbex/lib.py Line: 227
199
- def read_file(path)
199
+ def read_file(path):
200
200
 
201
201
  # File: symbex/lib.py Line: 253
202
- class TypeSummary
202
+ class TypeSummary:
203
203
 
204
204
  # File: symbex/lib.py Line: 258
205
- def type_summary(node: AST) -> Optional[TypeSummary]
205
+ def type_summary(node: AST) -> Optional[TypeSummary]:
206
206
 
207
207
  # File: symbex/lib.py Line: 304
208
- def quoted_string(s)
208
+ def quoted_string(s):
209
209
 
210
210
  # File: symbex/lib.py Line: 315
211
- def import_line_for_function(function_name: str, filepath: str, possible_root_dirs: List[str]) -> str
211
+ def import_line_for_function(function_name: str, filepath: str, possible_root_dirs: List[str]) -> str:
212
212
 
213
213
  # File: symbex/lib.py Line: 37
214
- def code_for_node(code: str, node: AST, class_name: str, signatures: bool, docstrings: bool) -> Tuple[(str, int)]
214
+ def code_for_node(code: str, node: AST, class_name: str, signatures: bool, docstrings: bool) -> Tuple[(str, int)]:
215
215
 
216
216
  # File: symbex/lib.py Line: 71
217
- def add_docstring(definition: str, node: AST, docstrings: bool, is_method: bool) -> str
217
+ def add_docstring(definition: str, node: AST, docstrings: bool, is_method: bool) -> str:
218
218
 
219
219
  # File: symbex/lib.py Line: 82
220
- def match(name: str, symbols: Iterable[str]) -> bool
220
+ def match(name: str, symbols: Iterable[str]) -> bool:
221
221
  ```
222
222
  <!-- [[[end]]] -->
223
223
  This can be combined with other options, or you can run `symbex -s` to see every symbol in the current directory and its subdirectories.
@@ -239,7 +239,7 @@ cog.out(
239
239
  ```python
240
240
  # File: symbex/lib.py Line: 82
241
241
  # from symbex.lib import match
242
- def match(name: str, symbols: Iterable[str]) -> bool
242
+ def match(name: str, symbols: Iterable[str]) -> bool:
243
243
  ```
244
244
  <!-- [[[end]]] -->
245
245
  To suppress the `# File: ...` comments, use `--no-file` or `-n`.
@@ -259,7 +259,7 @@ cog.out(
259
259
  ]]] -->
260
260
  ```python
261
261
  # from symbex.lib import match
262
- def match(name: str, symbols: Iterable[str]) -> bool
262
+ def match(name: str, symbols: Iterable[str]) -> bool:
263
263
  ```
264
264
  <!-- [[[end]]] -->
265
265
 
@@ -276,7 +276,7 @@ cog.out(
276
276
  ]]] -->
277
277
  ```python
278
278
  # File: symbex/lib.py Line: 82
279
- def match(name: str, symbols: Iterable[str]) -> bool
279
+ def match(name: str, symbols: Iterable[str]) -> bool:
280
280
  "Returns True if name matches any of the symbols, resolving wildcards"
281
281
  ```
282
282
  <!-- [[[end]]] -->
@@ -1,7 +1,7 @@
1
1
  from setuptools import setup
2
2
  import os
3
3
 
4
- VERSION = "1.3"
4
+ VERSION = "1.3.1"
5
5
 
6
6
 
7
7
  def get_long_description():
@@ -169,7 +169,7 @@ def function_definition(function_node: AST):
169
169
  if isinstance(function_node, AsyncFunctionDef):
170
170
  def_ = "async def "
171
171
 
172
- return f"{def_}{function_name}({arguments_str}){return_annotation}"
172
+ return f"{def_}{function_name}({arguments_str}){return_annotation}:"
173
173
 
174
174
 
175
175
  def class_definition(class_def):
@@ -201,7 +201,7 @@ def class_definition(class_def):
201
201
  if signature:
202
202
  signature = f"({signature})"
203
203
 
204
- class_definition = f"class {class_def.name}{signature}"
204
+ class_definition = f"class {class_def.name}{signature}:"
205
205
 
206
206
  return class_definition
207
207
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: symbex
3
- Version: 1.3
3
+ Version: 1.3.1
4
4
  Summary: Find the Python code for specified symbols
5
5
  Home-page: https://github.com/simonw/symbex
6
6
  Author: Simon Willison
@@ -199,40 +199,40 @@ cog.out(
199
199
  ]]] -->
200
200
  ```python
201
201
  # File: symbex/lib.py Line: 107
202
- def function_definition(function_node: AST)
202
+ def function_definition(function_node: AST):
203
203
 
204
204
  # File: symbex/lib.py Line: 13
205
- def find_symbol_nodes(code: str, filename: str, symbols: Iterable[str]) -> List[Tuple[(AST, Optional[str])]]
205
+ def find_symbol_nodes(code: str, filename: str, symbols: Iterable[str]) -> List[Tuple[(AST, Optional[str])]]:
206
206
 
207
207
  # File: symbex/lib.py Line: 175
208
- def class_definition(class_def)
208
+ def class_definition(class_def):
209
209
 
210
210
  # File: symbex/lib.py Line: 209
211
- def annotation_definition(annotation: AST) -> str
211
+ def annotation_definition(annotation: AST) -> str:
212
212
 
213
213
  # File: symbex/lib.py Line: 227
214
- def read_file(path)
214
+ def read_file(path):
215
215
 
216
216
  # File: symbex/lib.py Line: 253
217
- class TypeSummary
217
+ class TypeSummary:
218
218
 
219
219
  # File: symbex/lib.py Line: 258
220
- def type_summary(node: AST) -> Optional[TypeSummary]
220
+ def type_summary(node: AST) -> Optional[TypeSummary]:
221
221
 
222
222
  # File: symbex/lib.py Line: 304
223
- def quoted_string(s)
223
+ def quoted_string(s):
224
224
 
225
225
  # File: symbex/lib.py Line: 315
226
- def import_line_for_function(function_name: str, filepath: str, possible_root_dirs: List[str]) -> str
226
+ def import_line_for_function(function_name: str, filepath: str, possible_root_dirs: List[str]) -> str:
227
227
 
228
228
  # File: symbex/lib.py Line: 37
229
- def code_for_node(code: str, node: AST, class_name: str, signatures: bool, docstrings: bool) -> Tuple[(str, int)]
229
+ def code_for_node(code: str, node: AST, class_name: str, signatures: bool, docstrings: bool) -> Tuple[(str, int)]:
230
230
 
231
231
  # File: symbex/lib.py Line: 71
232
- def add_docstring(definition: str, node: AST, docstrings: bool, is_method: bool) -> str
232
+ def add_docstring(definition: str, node: AST, docstrings: bool, is_method: bool) -> str:
233
233
 
234
234
  # File: symbex/lib.py Line: 82
235
- def match(name: str, symbols: Iterable[str]) -> bool
235
+ def match(name: str, symbols: Iterable[str]) -> bool:
236
236
  ```
237
237
  <!-- [[[end]]] -->
238
238
  This can be combined with other options, or you can run `symbex -s` to see every symbol in the current directory and its subdirectories.
@@ -254,7 +254,7 @@ cog.out(
254
254
  ```python
255
255
  # File: symbex/lib.py Line: 82
256
256
  # from symbex.lib import match
257
- def match(name: str, symbols: Iterable[str]) -> bool
257
+ def match(name: str, symbols: Iterable[str]) -> bool:
258
258
  ```
259
259
  <!-- [[[end]]] -->
260
260
  To suppress the `# File: ...` comments, use `--no-file` or `-n`.
@@ -274,7 +274,7 @@ cog.out(
274
274
  ]]] -->
275
275
  ```python
276
276
  # from symbex.lib import match
277
- def match(name: str, symbols: Iterable[str]) -> bool
277
+ def match(name: str, symbols: Iterable[str]) -> bool:
278
278
  ```
279
279
  <!-- [[[end]]] -->
280
280
 
@@ -291,7 +291,7 @@ cog.out(
291
291
  ]]] -->
292
292
  ```python
293
293
  # File: symbex/lib.py Line: 82
294
- def match(name: str, symbols: Iterable[str]) -> bool
294
+ def match(name: str, symbols: Iterable[str]) -> bool:
295
295
  "Returns True if name matches any of the symbols, resolving wildcards"
296
296
  ```
297
297
  <!-- [[[end]]] -->
@@ -288,8 +288,8 @@ def test_filters(args, expected):
288
288
  for line in result.stdout.splitlines()
289
289
  if line.strip() and not line.startswith("# File:")
290
290
  ]
291
- # We only match up to the opening "("
292
- defs = [line.split("(")[0] for line in lines]
291
+ # We only match up to the opening "(" or ":"
292
+ defs = [line.split("(")[0].split(":")[0] for line in lines]
293
293
  assert defs == expected
294
294
 
295
295
  # Test the --count option too
@@ -151,23 +151,23 @@ def test_fixture(directory_full_of_code, monkeypatch, args, expected):
151
151
  (
152
152
  ["foo*", "--silent"],
153
153
  "# File: foo.py Line: 1\n"
154
- "def foo1()\n"
154
+ "def foo1():\n"
155
155
  "\n"
156
156
  "# File: foo.py Line: 5\n"
157
- "def foo2()",
157
+ "def foo2():",
158
158
  ),
159
- (["BarClass", "--silent"], "# File: bar.py Line: 1\n" "class BarClass"),
159
+ (["BarClass", "--silent"], "# File: bar.py Line: 1\n" "class BarClass:"),
160
160
  (
161
161
  ["baz", "--silent"],
162
162
  (
163
163
  "# File: nested.py/x/baz.py Line: 1\n"
164
- 'def baz(delimiter=", ", type=str)'
164
+ 'def baz(delimiter=", ", type=str):'
165
165
  ),
166
166
  ),
167
167
  # Test for the --module option
168
168
  (
169
169
  ["-m", "pathlib", "Path", "--silent", "-in"],
170
- ("# from pathlib import Path\nclass Path(PurePath)"),
170
+ ("# from pathlib import Path\nclass Path(PurePath):"),
171
171
  ),
172
172
  ),
173
173
  )
@@ -69,7 +69,7 @@ def test_method_symbols():
69
69
  assert result.exit_code == 0
70
70
  assert result.stdout == (
71
71
  "# File: tests/example_symbols.py Class: ClassWithMethods Line: 91\n"
72
- " async def async_method(a, b, c)\n"
72
+ " async def async_method(a, b, c):\n"
73
73
  "\n"
74
74
  )
75
75
 
@@ -88,20 +88,20 @@ def test_docstrings():
88
88
  assert result.exit_code == 0
89
89
  expected = """
90
90
  # File: tests/example_symbols.py Line: X
91
- def func_no_args()
91
+ def func_no_args():
92
92
  "This has a single line docstring"
93
93
 
94
94
  # File: tests/example_symbols.py Line: X
95
- def func_positional_args(a, b, c)
95
+ def func_positional_args(a, b, c):
96
96
  \"\"\"This has a
97
97
  multi-line docstring\"\"\"
98
98
 
99
99
  # File: tests/example_symbols.py Class: ClassForTypedTests Line: X
100
- def method_fully_typed(self, a: int, b: str) -> bool
100
+ def method_fully_typed(self, a: int, b: str) -> bool:
101
101
  "Single line"
102
102
 
103
103
  # File: tests/example_symbols.py Class: ClassForTypedTests Line: X
104
- def method_partially_typed(self, a: int, b) -> bool
104
+ def method_partially_typed(self, a: int, b) -> bool:
105
105
  \"\"\"Multiple
106
106
  lines\"\"\"
107
107
  """.strip()
@@ -126,15 +126,15 @@ def test_imports(no_file):
126
126
  expected = """
127
127
  # File: tests/example_symbols.py Line: 28
128
128
  # from example_symbols import func_arbitrary_positional_args
129
- def func_arbitrary_positional_args(*args)
129
+ def func_arbitrary_positional_args(*args):
130
130
 
131
131
  # File: tests/example_symbols.py Line: 33
132
132
  # from example_symbols import func_arbitrary_keyword_args
133
- def func_arbitrary_keyword_args(**kwargs)
133
+ def func_arbitrary_keyword_args(**kwargs):
134
134
 
135
135
  # File: tests/example_symbols.py Line: 38
136
136
  # from example_symbols import func_arbitrary_args
137
- def func_arbitrary_args(*args, **kwargs)
137
+ def func_arbitrary_args(*args, **kwargs):
138
138
  """.strip()
139
139
  if no_file:
140
140
  lines = expected.split("\n")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes