Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column comment type #238

Open
sdfordham opened this issue Feb 10, 2022 · 0 comments · May be fixed by #239
Open

Column comment type #238

sdfordham opened this issue Feb 10, 2022 · 0 comments · May be fixed by #239

Comments

@sdfordham
Copy link

sdfordham commented Feb 10, 2022

Running the SQLAlchemy inspect method on an existing MySQL server on a table with a column with an empty comment field is returning comment=None so I guess comment to be Optional[str] but mypy output complains that it needs to be str. Actually I don't know why since the repo code shows:

comment: Optional[str] = ...

Here is a MWE:

from sqlalchemy import Column
from sqlalchemy.ext.declarative import declarative_base


Base = declarative_base()


class MyTable(Base):
    id = Column('id', comment=None)

and output:

test.py:10: error: No overload variant of "Column" matches argument types "str", "None"
test.py:10: note: Possible overload variants:
test.py:10: note:     def [_T] Column(self, name: str, type_: Type[TypeEngine[_T]], *args: Any, autoincrement: Union[bool, str] = ..., default: Any = ..., doc: str = ..., key: str = ..., index: bool = ..., info: Mapping[str, Any] = ..., nullable: bool = ..., onupdate: Any = ..., primary_key: bool = ..., server_default: Any = ..., server_onupdate: Union[FetchedValue, FunctionElement[Any]] = ..., quote: Optional[bool] = ..., unique: bool = ..., system: bool = ..., comment: str = ...) -> Column[_T]
test.py:10: note:     def [_T] Column(self, name: str, type_: TypeEngine[_T], *args: Any, autoincrement: Union[bool, str] = ..., default: Any = ..., doc: str = ..., key: str = ..., index: bool = ..., info: Mapping[str, Any] = ..., nullable: bool = ..., onupdate: Any = ..., primary_key: bool = ..., server_default: Any = ..., server_onupdate: Union[FetchedValue, FunctionElement[Any]] = ..., quote: Optional[bool] = ..., unique: bool = ..., system: bool = ..., comment: str = ...) -> Column[_T]
test.py:10: note:     def [_T] Column(self, name: str, type_: ForeignKey, *args: Any, autoincrement: Union[bool, str] = ..., default: Any = ..., doc: str = 
..., key: str = ..., index: bool = ..., info: Mapping[str, Any] = ..., nullable: bool = ..., onupdate: Any = ..., primary_key: bool = ..., server_default: Any = ..., server_onupdate: Union[FetchedValue, FunctionElement[Any]] = ..., quote: Optional[bool] = ..., unique: bool = ..., system: bool = ..., comment: str = ...) -> Column[_T]
.., key: str = ..., index: bool = ..., info: Mapping[str, Any] = ..., nullable: bool = ..., onupdate: Any = ..., primary_key: bool = ..., server_default: Any = ..., server_onupdate: Union[FetchedValue, FunctionElement[Any]] = ..., quote: Optional[bool] = ..., unique: bool = ..., system: bool = ..., comment: str = ...) -> Column[_T]
test.py:10: note:     def [_T] Column(self, type_: TypeEngine[_T], *args: Any, autoincrement: Union[bool, str] = ..., default: Any = ..., doc: str = ..., key: str = ..., index: bool = ..., info: Mapping[str, Any] = ..., nullable: bool = ..., onupdate: Any = ..., primary_key: bool = ..., server_default: Any = ..., server_onupdate: Union[FetchedValue, FunctionElement[Any]] = ..., quote: Optional[bool] = ..., unique: bool = ..., system: bool = ..., comment: str = ...) -> Column[_T]
test.py:10: note:     def [_T] Column(self, type_: ForeignKey, *args: Any, autoincrement: Union[bool, str] = ..., default: Any = ..., doc: str = ..., key: str = ..., index: bool = ..., info: Mapping[str, Any] = ..., nullable: bool = ..., onupdate: Any = ..., primary_key: bool = ..., server_default: Any = ..., server_onupdate: Union[FetchedValue, FunctionElement[Any]] = ..., quote: Optional[bool] = ..., unique: bool = ..., system: bool = ..., comment: str = ...) -> Column[_T]
Found 1 error in 1 file (checked 1 source file)
sdfordham added a commit to sdfordham/sqlalchemy-stubs that referenced this issue Feb 12, 2022
@sdfordham sdfordham linked a pull request Feb 12, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant