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

Make type annotation optional for self argument of class methods #1578

Closed
EmilyBourne opened this issue Oct 23, 2023 · 0 comments · Fixed by #1626
Closed

Make type annotation optional for self argument of class methods #1578

EmilyBourne opened this issue Oct 23, 2023 · 0 comments · Fixed by #1626
Assignees
Labels
Classes enhancement good-second-issue Relatively simple issue involving multiple zone in the code Type specification

Comments

@EmilyBourne
Copy link
Member

Describe the feature

According to PEP 484 we shouldn't need to annotate the first argument of a class method. We should make this annotation optional.

Test Code

Provide code which does not currently work but which should do when this issue is fixed:

class MyClass:
    def __init__(self, param1 : 'float[:]'):
        self.param1 = param1
        print("MyClass Object created!")
        print(self.param1)

Proposed Solution

The annotation should be added in the syntactic stage if it is not already present

@EmilyBourne EmilyBourne mentioned this issue Oct 23, 2023
20 tasks
@EmilyBourne EmilyBourne added the good-second-issue Relatively simple issue involving multiple zone in the code label Nov 1, 2023
@EmilyBourne EmilyBourne self-assigned this Nov 18, 2023
yguclu pushed a commit that referenced this issue Nov 22, 2023
…1626)

Make type annotation optional for the first argument (usually named
`self`) of bound methods to conform to PEP 484. Fixes #1578.

This is done by adding the missing type annotation in the syntactic
stage if there is no annotation present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Classes enhancement good-second-issue Relatively simple issue involving multiple zone in the code Type specification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant