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

Use zero-argument super() #1726

Merged
merged 3 commits into from
Nov 2, 2023
Merged

Commits on Nov 2, 2023

  1. Revise some comments and strings

    These are a few things I had missed in gitpython-developers#1725.
    EliahKagan committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    36a3b76 View commit details
    Browse the repository at this point in the history
  2. Use zero-argument super() where applicable

    This replaces 2-argument super(...) calls with zero-argument
    super() calls, where doing so preserves the exact semantics. This
    turns out to be everywhere in the actual code (now all uses of the
    super builtin are calls to it with zero arguments), and also in
    most places code was discussed in comments.
    
    The single exception, occurring in comments (technically a string
    literal, but being used as a comment), appears in
    git.objects.util.TraversableIterableObj, where super(Commit, self),
    rather than super(TraversableIterableObj, self) which would have
    the same meaning as super(), is shown. It may be that this should
    be changed, but such a revision would not signify identical
    semantics, and may require other changes to preserve or recover
    clarity or documentary accuracy.
    EliahKagan committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    a47e46d View commit details
    Browse the repository at this point in the history
  3. Don't swallow AttributeError from super().setUp()

    This is conceptually independent of the immediately preceding
    super() call refactoring, but serves the same goal of simplifying
    and clarifying super() calls.
    
    In test.performance.lib, the TestBigRepoR and TestBigRepoRW
    classes' setUp methods had calls to setUp through super proxies,
    which were wrapped in try-blocks to swallow AttributeError
    exceptions. This removes that, relying on the presence of setUp
    methods in some parent or sibling class in the MRO.
    
    The intent appeared to be solely to account for the possibility
    that no class in the MRO would define a setUp method. However,
    the unittest.TestCase base class defines noop setUp and tearDown
    methods to ensure this does not have to be done.
    
    This may also make the code more robust, because the form in which
    AttributeError was being swallowed was:
    
        try:
            super().setUp()
        except AttributeError:
            pass
    
    But that has the disadvantage of also catching AttributeError due
    to a bug or other problem in code that runs *in* an ancestor or
    sibling class's existing setUp method. This could alternatively
    be addressed by using:
    
        try:
            other_setUp = super().setUp
        except AttributeError:
            pass
        else:
            other_setUp()
    
    However, because unittest.TestCase provides empty setUp and
    tearDown methods to allow such special-casing to be avoided (both
    in cases like this and for the test runner), this isn't needed.
    EliahKagan committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    9113177 View commit details
    Browse the repository at this point in the history