Skip to content

Conversation

@DanielNoord
Copy link
Collaborator

Steps

  • Write a good description on what the PR does.

Description

Had this laying around for quite some time. Mostly moving around some stuff and making sure keywords is not reassigned to another type.

Type of Changes

Type
🔨 Refactoring

Related Issue

@DanielNoord DanielNoord added the Maintenance Discussion or action around maintaining astroid or the dev workflow label Mar 12, 2022
self.args = args # Call positional arguments
if keywords:
keywords = [(arg.arg, arg.value) for arg in keywords]
keywords_list = [(arg.arg, arg.value) for arg in keywords]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of putting the type in the variable name: it increase the mental load, you can check the type if you need it and the plural form indicate it's an iterable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to keywords_tuples. Open for any better suggestions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to keywords_tuples. Open for any better suggestions.

I think that's worse, let's just leave it at keywords. It's assigned to self.keywords after all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that keywords was fine :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mypy will complain then. keywords is defined as keywords: Optional[List["Keyword"]] = None, on L161. That's why I introduced the name change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keywords: List[Tuple[str, str]] = [(arg.arg, arg.value) for arg in keywords]

Will raise a no-redef warning..

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas Mar 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe keywords_as_list then ? (or keywords_as_tuple)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe keywords_as_list then ?

They are a list already. Maybe keywords_list wasn't that bad after all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with arg_value_pairs 😅 Is that okay?

if TYPE_CHECKING:
from astroid.nodes.node_classes import Keyword, NodeNG

_InferenceCache = MutableMapping[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why it was MutableMapping instead of Dict?

Do we want to start adding a Type suffix to type aliases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR that added it is #1009.

Perhaps adding Type is something to do after we can run mypy successfully? I'm still running into issues with types not actually being correct or missing information. I think we can do a "cleanup" mypy PR after we can get it to pass.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR that added it is #1009.

Let's use Dict. Usually the return type should be precise whereas the parameter type should be open. Sequence["NodeNG"] is ok though I think. We assign a list converted to a tuple to it.

Perhaps adding Type is something to do after we can run mypy successfully? I'm still running into issues with types not actually being correct or missing information. I think we can do a "cleanup" mypy PR after we can get it to pass.

👍🏻

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.12.0 milestone Mar 12, 2022
@DanielNoord DanielNoord requested a review from cdce8p March 12, 2022 12:25
@cdce8p cdce8p merged commit 014a04c into pylint-dev:main Mar 14, 2022
@DanielNoord DanielNoord deleted the typing-context branch March 14, 2022 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance Discussion or action around maintaining astroid or the dev workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants