Skip to content

Conversation

@dcbaker
Copy link
Member

@dcbaker dcbaker commented Dec 5, 2019

This cleans up a few things I noticed from the recent lgtm changes that are either incorrect, or were correct and simpler before the changes.

There are three problems:

1) Dunders like `__lt__` and `__gt__` don't return bool, they return
   either a bool or the NotImplemented singleton to signal that they don't
   know how to be compared.
2) The don't take type object, the take `typing.Any`
3) They need to return NotImplemented if the comparison is not
   implemented, this allows python to try the inverse dunder from the
   other object. If that object returns NotImplemented as well a
   TypeError is raised.
`from foo import` should be used sparingly because of namespace
pollution, especially since those names will be exported
unconditionally. For typing this is extra annoying because anytime
someone wants to use another symbol from the typing module they have to
add it to the import line. Use `import typing` to avoid all of this.
@dcbaker dcbaker changed the title Fix lgtm problems Fix lgtm cleanup problems Dec 5, 2019
There are two awful things about CompilerArgs, one is that it directly
inherits from list, and there are a lot of subtle gotcahs with
inheriting from builtin types. The second is that the class allows
arguments to be passed in whatever order. That's bad. This also fully
annotates the CompilerArgs class, so mypy can type check it for us.
…itialization"

This partially reverts commit fe853ee.

In particular this reverts the changes to the DynamicLinker __init__
methods. Frankly this is *bad* because it allows a mixin class (which
should not be directly instantiated) to be directly instantiated, and
complicates the init process. It also increases the amount of code for
zero gain, and makes the code less resilient to refactors.
@lgtm-com
Copy link

lgtm-com bot commented Dec 5, 2019

This pull request introduces 4 alerts and fixes 3 when merging 294dcb0 into bc5864b - view on LGTM.com

new alerts:

  • 4 for Missing call to __init__ during object initialization

fixed alerts:

  • 3 for Non-standard exception raised in special method

@dcbaker
Copy link
Member Author

dcbaker commented Dec 5, 2019

LGTM is just buggy about super().__init__, here's the upstream bug: github/codeql#2455

@dcbaker
Copy link
Member Author

dcbaker commented Dec 5, 2019

@jpakkane, I'd really like to merge this before the LD stuff as it resolves all of the merge/rebase conflicts.

@jpakkane jpakkane merged commit c00e17b into mesonbuild:master Dec 5, 2019
@dcbaker dcbaker deleted the fix-lgtm-problems branch December 5, 2019 21:42
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 this pull request may close these issues.

3 participants