Proper type annotations for PillarServer.db()
This commit is contained in:
@@ -7,6 +7,7 @@ import logging
|
|||||||
import logging.config
|
import logging.config
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import typing
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
@@ -15,6 +16,8 @@ from eve import Eve
|
|||||||
import flask
|
import flask
|
||||||
from flask import render_template, request
|
from flask import render_template, request
|
||||||
from flask.templating import TemplateNotFound
|
from flask.templating import TemplateNotFound
|
||||||
|
import pymongo.collection
|
||||||
|
import pymongo.database
|
||||||
|
|
||||||
from pillar.api import custom_field_validation
|
from pillar.api import custom_field_validation
|
||||||
from pillar.api.utils import authentication
|
from pillar.api.utils import authentication
|
||||||
@@ -551,11 +554,9 @@ class PillarServer(Eve):
|
|||||||
|
|
||||||
pprint(links)
|
pprint(links)
|
||||||
|
|
||||||
def db(self, collection_name: str=None):
|
def db(self, collection_name: str=None) \
|
||||||
"""Returns the MongoDB database.
|
-> typing.Union[pymongo.collection.Collection, pymongo.database.Database]:
|
||||||
|
"""Returns the MongoDB database, or the collection (if given)"""
|
||||||
:rtype: flask_pymongo.PyMongo
|
|
||||||
"""
|
|
||||||
|
|
||||||
if collection_name:
|
if collection_name:
|
||||||
return self.data.driver.db[collection_name]
|
return self.data.driver.db[collection_name]
|
||||||
|
Reference in New Issue
Block a user