python-plugins 1.0.3__py3-none-any.whl → 1.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- __version__ = "1.0.3"
1
+ __version__ = "1.0.4"
@@ -0,0 +1,311 @@
1
+ """Example Google style docstrings.
2
+
3
+ This module demonstrates documentation as specified by the `Google Python
4
+ Style Guide`_. Docstrings may extend over multiple lines. Sections are created
5
+ with a section header and a colon followed by a block of indented text.
6
+
7
+ Example:
8
+ Examples can be given using either the ``Example`` or ``Examples``
9
+ sections. Sections support any reStructuredText formatting, including
10
+ literal blocks::
11
+
12
+ $ python example_google.py
13
+
14
+ Section breaks are created by resuming unindented text. Section breaks
15
+ are also implicitly created anytime a new section starts.
16
+
17
+ Attributes:
18
+ module_level_variable1 (int): Module level variables may be documented in
19
+ either the ``Attributes`` section of the module docstring, or in an
20
+ inline docstring immediately following the variable.
21
+
22
+ Either form is acceptable, but the two should not be mixed. Choose
23
+ one convention to document module level variables and be consistent
24
+ with it.
25
+
26
+ Todo:
27
+ * For module TODOs
28
+ * You have to also use ``sphinx.ext.todo`` extension
29
+
30
+ .. _Google Python Style Guide:
31
+ https://google.github.io/styleguide/pyguide.html
32
+
33
+ """
34
+
35
+ module_level_variable1 = 12345
36
+
37
+ module_level_variable2 = 98765
38
+ """int: Module level variable documented inline.
39
+
40
+ The docstring may span multiple lines. The type may optionally be specified
41
+ on the first line, separated by a colon.
42
+ """
43
+
44
+
45
+ def function_with_types_in_docstring(param1, param2):
46
+ """Example function with types documented in the docstring.
47
+
48
+ :pep:`484` type annotations are supported. If attribute, parameter, and
49
+ return types are annotated according to `PEP 484`, they do not need to be
50
+ included in the docstring:
51
+
52
+ Args:
53
+ param1 (int): The first parameter.
54
+ param2 (str): The second parameter.
55
+
56
+ Returns:
57
+ bool: The return value. True for success, False otherwise.
58
+ """
59
+
60
+
61
+ def function_with_pep484_type_annotations(param1: int, param2: str) -> bool:
62
+ """Example function with PEP 484 type annotations.
63
+
64
+ Args:
65
+ param1: The first parameter.
66
+ param2: The second parameter.
67
+
68
+ Returns:
69
+ The return value. True for success, False otherwise.
70
+
71
+ """
72
+
73
+
74
+ def module_level_function(param1, param2=None, *args, **kwargs):
75
+ """This is an example of a module level function.
76
+
77
+ Function parameters should be documented in the ``Args`` section. The name
78
+ of each parameter is required. The type and description of each parameter
79
+ is optional, but should be included if not obvious.
80
+
81
+ If ``*args`` or ``**kwargs`` are accepted,
82
+ they should be listed as ``*args`` and ``**kwargs``.
83
+
84
+ The format for a parameter is::
85
+
86
+ name (type): description
87
+ The description may span multiple lines. Following
88
+ lines should be indented. The "(type)" is optional.
89
+
90
+ Multiple paragraphs are supported in parameter
91
+ descriptions.
92
+
93
+ Args:
94
+ param1 (int): The first parameter.
95
+ param2 (:obj:`str`, optional): The second parameter. Defaults to None.
96
+ Second line of description should be indented.
97
+ *args: Variable length argument list.
98
+ **kwargs: Arbitrary keyword arguments.
99
+
100
+ Returns:
101
+ bool: True if successful, False otherwise.
102
+
103
+ The return type is optional and may be specified at the beginning of
104
+ the ``Returns`` section followed by a colon.
105
+
106
+ The ``Returns`` section may span multiple lines and paragraphs.
107
+ Following lines should be indented to match the first line.
108
+
109
+ The ``Returns`` section supports any reStructuredText formatting,
110
+ including literal blocks::
111
+
112
+ {
113
+ 'param1': param1,
114
+ 'param2': param2,
115
+ }
116
+
117
+ Raises:
118
+ AttributeError: The ``Raises`` section is a list of all exceptions
119
+ that are relevant to the interface.
120
+ ValueError: If `param2` is equal to `param1`.
121
+
122
+ """
123
+ if param1 == param2:
124
+ msg = 'param1 may not be equal to param2'
125
+ raise ValueError(msg)
126
+ return True
127
+
128
+
129
+ def example_generator(n):
130
+ """Generators have a ``Yields`` section instead of a ``Returns`` section.
131
+
132
+ Args:
133
+ n (int): The upper limit of the range to generate, from 0 to `n` - 1.
134
+
135
+ Yields:
136
+ int: The next number in the range of 0 to `n` - 1.
137
+
138
+ Examples:
139
+ Examples should be written in doctest format, and should illustrate how
140
+ to use the function.
141
+
142
+ >>> print([i for i in example_generator(4)])
143
+ [0, 1, 2, 3]
144
+
145
+ """
146
+ yield from range(n)
147
+
148
+
149
+ class ExampleError(Exception):
150
+ """Exceptions are documented in the same way as classes.
151
+
152
+ The __init__ method may be documented in either the class level
153
+ docstring, or as a docstring on the __init__ method itself.
154
+
155
+ Either form is acceptable, but the two should not be mixed. Choose one
156
+ convention to document the __init__ method and be consistent with it.
157
+
158
+ Note:
159
+ Do not include the `self` parameter in the ``Args`` section.
160
+
161
+ Args:
162
+ msg (str): Human readable string describing the exception.
163
+ code (:obj:`int`, optional): Error code.
164
+
165
+ Attributes:
166
+ msg (str): Human readable string describing the exception.
167
+ code (int): Exception error code.
168
+
169
+ """
170
+
171
+ def __init__(self, msg, code):
172
+ self.msg = msg
173
+ self.code = code
174
+
175
+
176
+ class ExampleClass:
177
+ """The summary line for a class docstring should fit on one line.
178
+
179
+ If the class has public attributes, they may be documented here
180
+ in an ``Attributes`` section and follow the same formatting as a
181
+ function's ``Args`` section. Alternatively, attributes may be documented
182
+ inline with the attribute's declaration (see __init__ method below).
183
+
184
+ Properties created with the ``@property`` decorator should be documented
185
+ in the property's getter method.
186
+
187
+ Attributes:
188
+ attr1 (str): Description of `attr1`.
189
+ attr2 (:obj:`int`, optional): Description of `attr2`.
190
+
191
+ """
192
+
193
+ def __init__(self, param1, param2, param3):
194
+ """Example of docstring on the __init__ method.
195
+
196
+ The __init__ method may be documented in either the class level
197
+ docstring, or as a docstring on the __init__ method itself.
198
+
199
+ Either form is acceptable, but the two should not be mixed. Choose one
200
+ convention to document the __init__ method and be consistent with it.
201
+
202
+ Note:
203
+ Do not include the `self` parameter in the ``Args`` section.
204
+
205
+ Args:
206
+ param1 (str): Description of `param1`.
207
+ param2 (:obj:`int`, optional): Description of `param2`. Multiple
208
+ lines are supported.
209
+ param3 (list(str)): Description of `param3`.
210
+
211
+ """
212
+ self.attr1 = param1
213
+ self.attr2 = param2
214
+ self.attr3 = param3 #: Doc comment *inline* with attribute
215
+
216
+ #: list(str): Doc comment *before* attribute, with type specified
217
+ self.attr4 = ['attr4']
218
+
219
+ self.attr5 = None
220
+ """str: Docstring *after* attribute, with type specified."""
221
+
222
+ @property
223
+ def readonly_property(self):
224
+ """str: Properties should be documented in their getter method."""
225
+ return 'readonly_property'
226
+
227
+ @property
228
+ def readwrite_property(self):
229
+ """list(str): Properties with both a getter and setter
230
+ should only be documented in their getter method.
231
+
232
+ If the setter method contains notable behavior, it should be
233
+ mentioned here.
234
+ """
235
+ return ['readwrite_property']
236
+
237
+ @readwrite_property.setter
238
+ def readwrite_property(self, value):
239
+ _ = value
240
+
241
+ def example_method(self, param1, param2):
242
+ """Class methods are similar to regular functions.
243
+
244
+ Note:
245
+ Do not include the `self` parameter in the ``Args`` section.
246
+
247
+ Args:
248
+ param1: The first parameter.
249
+ param2: The second parameter.
250
+
251
+ Returns:
252
+ True if successful, False otherwise.
253
+
254
+ """
255
+ return True
256
+
257
+ def __special__(self):
258
+ """By default special members with docstrings are not included.
259
+
260
+ Special members are any methods or attributes that start with and
261
+ end with a double underscore. Any special member with a docstring
262
+ will be included in the output, if
263
+ ``napoleon_include_special_with_doc`` is set to True.
264
+
265
+ This behavior can be enabled by changing the following setting in
266
+ Sphinx's conf.py::
267
+
268
+ napoleon_include_special_with_doc = True
269
+
270
+ """
271
+ pass
272
+
273
+ def __special_without_docstring__(self):
274
+ pass
275
+
276
+ def _private(self):
277
+ """By default private members are not included.
278
+
279
+ Private members are any methods or attributes that start with an
280
+ underscore and are *not* special. By default they are not included
281
+ in the output.
282
+
283
+ This behavior can be changed such that private members *are* included
284
+ by changing the following setting in Sphinx's conf.py::
285
+
286
+ napoleon_include_private_with_doc = True
287
+
288
+ """
289
+ pass
290
+
291
+ def _private_without_docstring(self):
292
+ pass
293
+
294
+
295
+ class ExamplePEP526Class:
296
+ """The summary line for a class docstring should fit on one line.
297
+
298
+ If the class has public attributes, they may be documented here
299
+ in an ``Attributes`` section and follow the same formatting as a
300
+ function's ``Args`` section. If ``napoleon_attr_annotations``
301
+ is True, types can be specified in the class body using ``PEP 526``
302
+ annotations.
303
+
304
+ Attributes:
305
+ attr1: Description of `attr1`.
306
+ attr2: Description of `attr2`.
307
+
308
+ """
309
+
310
+ attr1: str
311
+ attr2: int
@@ -0,0 +1,351 @@
1
+ """Example NumPy style docstrings.
2
+
3
+ This module demonstrates documentation as specified by the `NumPy
4
+ Documentation HOWTO`. Docstrings may extend over multiple lines. Sections
5
+ are created with a section header followed by an underline of equal length.
6
+
7
+ Example
8
+ -------
9
+ Examples can be given using either the ``Example`` or ``Examples``
10
+ sections. Sections support any reStructuredText formatting, including
11
+ literal blocks::
12
+
13
+ $ python example_numpy.py
14
+
15
+
16
+ Section breaks are created with two blank lines. Section breaks are also
17
+ implicitly created anytime a new section starts. Section bodies *may* be
18
+ indented:
19
+
20
+ Notes
21
+ -----
22
+ This is an example of an indented section. It's like any other section,
23
+ but the body is indented to help it stand out from surrounding text.
24
+
25
+ If a section is indented, then a section break is created by
26
+ resuming unindented text.
27
+
28
+ Attributes
29
+ ----------
30
+ module_level_variable1 : int
31
+ Module level variables may be documented in either the ``Attributes``
32
+ section of the module docstring, or in an inline docstring immediately
33
+ following the variable.
34
+
35
+ Either form is acceptable, but the two should not be mixed. Choose
36
+ one convention to document module level variables and be consistent
37
+ with it.
38
+
39
+
40
+ .. _NumPy docstring standard:
41
+ https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard
42
+
43
+ """
44
+
45
+ module_level_variable1 = 12345
46
+
47
+ module_level_variable2 = 98765
48
+ """int: Module level variable documented inline.
49
+
50
+ The docstring may span multiple lines. The type may optionally be specified
51
+ on the first line, separated by a colon.
52
+ """
53
+
54
+
55
+ def function_with_types_in_docstring(param1, param2):
56
+ """Example function with types documented in the docstring.
57
+
58
+ :pep:`484` type annotations are supported. If attribute, parameter, and
59
+ return types are annotated according to `PEP 484`, they do not need to be
60
+ included in the docstring:
61
+
62
+ Parameters
63
+ ----------
64
+ param1 : int
65
+ The first parameter.
66
+ param2 : str
67
+ The second parameter.
68
+
69
+ Returns
70
+ -------
71
+ bool
72
+ True if successful, False otherwise.
73
+ """
74
+
75
+
76
+ def function_with_pep484_type_annotations(param1: int, param2: str) -> bool:
77
+ """Example function with PEP 484 type annotations.
78
+
79
+ The return type must be duplicated in the docstring to comply
80
+ with the NumPy docstring style.
81
+
82
+ Parameters
83
+ ----------
84
+ param1
85
+ The first parameter.
86
+ param2
87
+ The second parameter.
88
+
89
+ Returns
90
+ -------
91
+ bool
92
+ True if successful, False otherwise.
93
+
94
+ """
95
+
96
+
97
+ def module_level_function(param1, param2=None, *args, **kwargs):
98
+ """This is an example of a module level function.
99
+
100
+ Function parameters should be documented in the ``Parameters`` section.
101
+ The name of each parameter is required. The type and description of each
102
+ parameter is optional, but should be included if not obvious.
103
+
104
+ If ``*args`` or ``**kwargs`` are accepted,
105
+ they should be listed as ``*args`` and ``**kwargs``.
106
+
107
+ The format for a parameter is::
108
+
109
+ name : type
110
+ description
111
+
112
+ The description may span multiple lines. Following lines
113
+ should be indented to match the first line of the description.
114
+ The ": type" is optional.
115
+
116
+ Multiple paragraphs are supported in parameter
117
+ descriptions.
118
+
119
+ Parameters
120
+ ----------
121
+ param1 : int
122
+ The first parameter.
123
+ param2 : :obj:`str`, optional
124
+ The second parameter.
125
+ *args
126
+ Variable length argument list.
127
+ **kwargs
128
+ Arbitrary keyword arguments.
129
+
130
+ Returns
131
+ -------
132
+ bool
133
+ True if successful, False otherwise.
134
+
135
+ The return type is not optional. The ``Returns`` section may span
136
+ multiple lines and paragraphs. Following lines should be indented to
137
+ match the first line of the description.
138
+
139
+ The ``Returns`` section supports any reStructuredText formatting,
140
+ including literal blocks::
141
+
142
+ {
143
+ 'param1': param1,
144
+ 'param2': param2,
145
+ }
146
+
147
+ Raises
148
+ ------
149
+ AttributeError
150
+ The ``Raises`` section is a list of all exceptions
151
+ that are relevant to the interface.
152
+ ValueError
153
+ If `param2` is equal to `param1`.
154
+
155
+ """
156
+ if param1 == param2:
157
+ msg = 'param1 may not be equal to param2'
158
+ raise ValueError(msg)
159
+ return True
160
+
161
+
162
+ def example_generator(n):
163
+ """Generators have a ``Yields`` section instead of a ``Returns`` section.
164
+
165
+ Parameters
166
+ ----------
167
+ n : int
168
+ The upper limit of the range to generate, from 0 to `n` - 1.
169
+
170
+ Yields
171
+ ------
172
+ int
173
+ The next number in the range of 0 to `n` - 1.
174
+
175
+ Examples
176
+ --------
177
+ Examples should be written in doctest format, and should illustrate how
178
+ to use the function.
179
+
180
+ >>> print([i for i in example_generator(4)])
181
+ [0, 1, 2, 3]
182
+
183
+ """
184
+ yield from range(n)
185
+
186
+
187
+ class ExampleError(Exception):
188
+ """Exceptions are documented in the same way as classes.
189
+
190
+ The __init__ method may be documented in either the class level
191
+ docstring, or as a docstring on the __init__ method itself.
192
+
193
+ Either form is acceptable, but the two should not be mixed. Choose one
194
+ convention to document the __init__ method and be consistent with it.
195
+
196
+ Note
197
+ ----
198
+ Do not include the `self` parameter in the ``Parameters`` section.
199
+
200
+ Parameters
201
+ ----------
202
+ msg : str
203
+ Human readable string describing the exception.
204
+ code : :obj:`int`, optional
205
+ Numeric error code.
206
+
207
+ Attributes
208
+ ----------
209
+ msg : str
210
+ Human readable string describing the exception.
211
+ code : int
212
+ Numeric error code.
213
+
214
+ """
215
+
216
+ def __init__(self, msg, code):
217
+ self.msg = msg
218
+ self.code = code
219
+
220
+
221
+ class ExampleClass:
222
+ """The summary line for a class docstring should fit on one line.
223
+
224
+ If the class has public attributes, they may be documented here
225
+ in an ``Attributes`` section and follow the same formatting as a
226
+ function's ``Args`` section. Alternatively, attributes may be documented
227
+ inline with the attribute's declaration (see __init__ method below).
228
+
229
+ Properties created with the ``@property`` decorator should be documented
230
+ in the property's getter method.
231
+
232
+ Attributes
233
+ ----------
234
+ attr1 : str
235
+ Description of `attr1`.
236
+ attr2 : :obj:`int`, optional
237
+ Description of `attr2`.
238
+
239
+ """
240
+
241
+ def __init__(self, param1, param2, param3):
242
+ """Example of docstring on the __init__ method.
243
+
244
+ The __init__ method may be documented in either the class level
245
+ docstring, or as a docstring on the __init__ method itself.
246
+
247
+ Either form is acceptable, but the two should not be mixed. Choose one
248
+ convention to document the __init__ method and be consistent with it.
249
+
250
+ Note
251
+ ----
252
+ Do not include the `self` parameter in the ``Parameters`` section.
253
+
254
+ Parameters
255
+ ----------
256
+ param1 : str
257
+ Description of `param1`.
258
+ param2 : list(str)
259
+ Description of `param2`. Multiple
260
+ lines are supported.
261
+ param3 : :obj:`int`, optional
262
+ Description of `param3`.
263
+
264
+ """
265
+ self.attr1 = param1
266
+ self.attr2 = param2
267
+ self.attr3 = param3 #: Doc comment *inline* with attribute
268
+
269
+ #: list(str): Doc comment *before* attribute, with type specified
270
+ self.attr4 = ['attr4']
271
+
272
+ self.attr5 = None
273
+ """str: Docstring *after* attribute, with type specified."""
274
+
275
+ @property
276
+ def readonly_property(self):
277
+ """str: Properties should be documented in their getter method."""
278
+ return 'readonly_property'
279
+
280
+ @property
281
+ def readwrite_property(self):
282
+ """list(str): Properties with both a getter and setter
283
+ should only be documented in their getter method.
284
+
285
+ If the setter method contains notable behavior, it should be
286
+ mentioned here.
287
+ """
288
+ return ['readwrite_property']
289
+
290
+ @readwrite_property.setter
291
+ def readwrite_property(self, value):
292
+ _ = value
293
+
294
+ def example_method(self, param1, param2):
295
+ """Class methods are similar to regular functions.
296
+
297
+ Note
298
+ ----
299
+ Do not include the `self` parameter in the ``Parameters`` section.
300
+
301
+ Parameters
302
+ ----------
303
+ param1
304
+ The first parameter.
305
+ param2
306
+ The second parameter.
307
+
308
+ Returns
309
+ -------
310
+ bool
311
+ True if successful, False otherwise.
312
+
313
+ """
314
+ return True
315
+
316
+ def __special__(self):
317
+ """By default special members with docstrings are not included.
318
+
319
+ Special members are any methods or attributes that start with and
320
+ end with a double underscore. Any special member with a docstring
321
+ will be included in the output, if
322
+ ``napoleon_include_special_with_doc`` is set to True.
323
+
324
+ This behavior can be enabled by changing the following setting in
325
+ Sphinx's conf.py::
326
+
327
+ napoleon_include_special_with_doc = True
328
+
329
+ """
330
+ pass
331
+
332
+ def __special_without_docstring__(self):
333
+ pass
334
+
335
+ def _private(self):
336
+ """By default private members are not included.
337
+
338
+ Private members are any methods or attributes that start with an
339
+ underscore and are *not* special. By default they are not included
340
+ in the output.
341
+
342
+ This behavior can be changed such that private members *are* included
343
+ by changing the following setting in Sphinx's conf.py::
344
+
345
+ napoleon_include_private_with_doc = True
346
+
347
+ """
348
+ pass
349
+
350
+ def _private_without_docstring(self):
351
+ pass
@@ -0,0 +1,31 @@
1
+ import os
2
+ import shutil
3
+
4
+
5
+ def remove(dir, dirname):
6
+ for root, dirs, files in os.walk(dir):
7
+ if "venv" in root or "git" in root:
8
+ continue
9
+ for dir in dirs:
10
+ if dir == dirname:
11
+ rm_path = os.path.join(root, dir)
12
+ print(f"Removing {rm_path}")
13
+ shutil.rmtree(rm_path)
14
+
15
+
16
+ def remove_pycache(dir="."):
17
+ remove(dir, "__pycache__")
18
+
19
+
20
+ def remove_ipynb_checkpoints(dir="."):
21
+ remove(dir, ".ipynb_checkpoints")
22
+
23
+
24
+ def find_empty_dirs(dir="."):
25
+ for root, dirs, files in os.walk(dir):
26
+ if "venv" in root or "git" in root:
27
+ continue
28
+ for dir in dirs:
29
+ dir_path = os.path.join(root, dir)
30
+ if not os.listdir(dir_path):
31
+ print(f"Empty dir: {dir_path}")
python_plugins/sqla/db.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from flask import Flask
2
2
  from flask import current_app
3
+ from flask import has_request_context
3
4
  from flask import g
4
5
  from sqlalchemy import create_engine
5
6
  from sqlalchemy.orm import sessionmaker
@@ -68,9 +69,9 @@ class Db:
68
69
 
69
70
  def _make_scoped_session(self, options):
70
71
  session_factory = sessionmaker(**options)
71
- return scoped_session(session_factory, scopefunc=self._get_app_g_id)
72
+ return scoped_session(session_factory, scopefunc=self._get_scope_id)
72
73
 
73
- def _get_app_g_id(self) -> int:
74
+ def _get_scope_id(self) -> int:
74
75
  return id(g._get_current_object())
75
76
 
76
77
  def _remove_session(self, exception=None):