棉花糖-sqlalchemy给出语法错误

时间:2019-11-12 12:34:00

标签: python python-3.6 marshmallow function-parameter

在python 3.5中安装marshmallow-sqlalchemy后,它向我显示语法错误。

我已经使用以下命令pip install marshmallow-sqlalchemy安装了它。

Traceback (most recent call last):
  File "run.py", line 1, in <module>
    from app import flask_app
  File "/var/www/html/mswipe-banner/mswipe-banner/app/__init__.py", line 10, in <module>
    from .models import *
  File "/var/www/html/mswipe-banner/mswipe-banner/app/models/__init__.py", line 1, in <module>
    from .banner import *
  File "/var/www/html/mswipe-banner/mswipe-banner/app/models/banner.py", line 1, in <module>
    from .base_model import *
  File "/var/www/html/mswipe-banner/mswipe-banner/app/models/base_model.py", line 1, in <module>
    from flask_marshmallow import Marshmallow
  File "/var/www/html/mswipe-banner/lib/python3.5/site-packages/flask_marshmallow/__init__.py", line 24, in <module>
    from . import sqla
  File "/var/www/html/mswipe-banner/lib/python3.5/site-packages/flask_marshmallow/sqla.py", line 13, in <module>
    import marshmallow_sqlalchemy as msqla
  File "/var/www/html/mswipe-banner/lib/python3.5/site-packages/marshmallow_sqlalchemy/__init__.py", line 1, in <module>
    from .schema import TableSchemaOpts, ModelSchemaOpts, TableSchema, ModelSchema
  File "/var/www/html/mswipe-banner/lib/python3.5/site-packages/marshmallow_sqlalchemy/schema.py", line 3, in <module>
    from .convert import ModelConverter
  File "/var/www/html/mswipe-banner/lib/python3.5/site-packages/marshmallow_sqlalchemy/convert.py", line 80
    ):
    ^
SyntaxError: invalid syntax

谢谢?

1 个答案:

答案 0 :(得分:1)

安装失败,因为marshmallow-sqlalchemy no longer supports Python 3.5。支持Python 3.5的最新版本是18.0,必须明确安装。

回溯中的特定错误是由this函数声明引起的:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
     let touch = touches.first
     if touch?.view != self.popView {
        dismissView()
    }
}

func dismissView() {
    self.popView.isHidden = true
    view?.backgroundColor = .white
}

Python 3.6包含一个change,以允许在函数参数列表中尾随逗号。在此更改之前,这些签名是合法的:

#current camera look thru
currentCamera = cmds.lookThru( q = True)
currentCamera  = (currentCamera + "Shape")
#list all cameras
cameraList = cmds.ls(type = ("camera"))
#list stratup cameras
excludeCameraList = ["frontShape","perspShape","sideShape","topShape","bottomShape","leftShape","backShape"]
#exclude startup cameras
nonStartupCameras = [x for x in cameraList if x not in excludeCameraList]
#find length
length = len(nonStartupCameras)
pos = 0
nextCamera = []
#loop thru all persp camera
for i in range(length):
    if currentCamera == nonStartupCameras[i]:
        pos = i+1
if pos >= length:
    pos = 0
#switch to next camera
nextCamera = nonStartupCameras[pos]
cmds.lookThru(nextCamera)

但这不是

def fields_for_model(
    self,
    model,
    *,
    include_fk=False,
    fields=None,
    exclude=None,
    base_fields=None,
    dict_cls=dict,
):

在版本18之后,参数列表中间的>>> def f(a, b, c=1,):pass ... >>> def f(a, b, *, c=1):pass ... >>> (表示仅关键字参数的开始)已添加到上述棉花糖-sqlalchemy函数签名中,作为删除2.7和3.5的过程的一部分兼容性。

相关问题