프로그래밍 연습하기

Pycharm Unexpected Argument 경고 본문

Python

Pycharm Unexpected Argument 경고

john.k 2021. 7. 31. 08:46
반응형

Pycharm을 사용해서 파이썬 코드를 작성하는데

전에 뜨지 않았던 Unexpected Argument라는 경고가 떴습니다.

Sqlalchemy의 테이블을 정의하고 사용하는 부분이었습니다.

 

Mixin 클래스를 만들어서 다중 상속 했더니

Argument를 예측하는 부분에서 문제가 생기는 것 같습니다.

 

class Mixin(object):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

 

이렇게 Mixin 클래스에 __init__을 정의해주어서 해결할 수 있었습니다.

 

참고

https://stackoverflow.com/questions/59606289/unexpected-argument-warning-on-mixin-with-python-3-6-flask-and-pycharm

 

Unexpected argument warning on mixin with Python 3.6, Flask, and PyCharm

I'm trying to implement a custom mixin in Python 3.6. Child classes would inherit its methods as well as base class. db = flask_sqlalchemy.SQLAlchemy() class CustomMixin(object): # {... __in...

stackoverflow.com

https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/mixins.html

 

Mixin and Custom Base Classes — SQLAlchemy 1.3 Documentation

In contrast to how __tablename__ and other special names are handled when used with declared_attr, when we mix in columns and properties (e.g. relationships, column properties, etc.), the function is invoked for the base class only in the hierarchy. Below,

docs.sqlalchemy.org

 

반응형
Comments