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

Arg/Kwarg rename passes liskov substitution rule #8314

Closed
JasonGilholme opened this issue Jan 22, 2020 · 1 comment
Closed

Arg/Kwarg rename passes liskov substitution rule #8314

JasonGilholme opened this issue Jan 22, 2020 · 1 comment

Comments

@JasonGilholme
Copy link

JasonGilholme commented Jan 22, 2020

  • Are you reporting a bug, or opening a feature request?

Reporting a bug

from typing import *


class Base(object):

    def fn(self, arg, kwarg=None):
        # type: (int, Optional[str]) -> None
        return


# Adding a kwarg passes - I think this correct
class Extension(Base):

    def fn(self, arg, kwarg=None, anotherKwarg=None):
        # type: (int, Optional[str], Optional[str]) -> None
        return


# Removing a kwarg errors - I think this correct
class RemovedKwargsExtension(Base):

    def fn(self, arg):
        # type: (int) -> None
        return


# Renaming args or kwargs passes - I expected this to error, at least for the kwarg rename.
class RenamedArgsExtension(Base):

    def fn(self, renamedArg, renamedKwarg=None):
        # type: (int, Optional[str]) -> None
        return
  • What is the actual behavior/output?
    RenamedArgsExtension passes type checking

  • What is the behavior/output you expect?
    I think RenamedArgsExtension should throw an error as the kwarg name has changed which will break the runtime. To a lesser degree the rename of the arg could also be considered an error, but that depends on if you're allowing the implicit kwarg -> positional arg usage.

  • What are the versions of mypy and Python you are using?
    mypy 0.761 running on python 3.6.4

  • What are the mypy flags you are using? (For example --strict-optional)
    mypy --strict /path/to/file.py

@JelleZijlstra
Copy link
Member

This is a duplicate of #1013.

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

No branches or pull requests

2 participants