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

snippet for def classmethod #5560

Closed
Cologler opened this issue May 6, 2019 · 11 comments
Closed

snippet for def classmethod #5560

Cologler opened this issue May 6, 2019 · 11 comments
Labels
area-editor-* User-facing catch-all area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug

Comments

@Cologler
Copy link

Cologler commented May 6, 2019

https://github.com/Microsoft/vscode-python/blob/b741e1af6d53cdf94765a6708964d489bd558ff8/snippets/python.json#L146-L153

should be

"body": [ 
    "@classmethod",
    "def ${1:funcname}(cls, ${2:parameter_list}):", 
    "\t${3:pass}" 
]
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label May 6, 2019
@karrtikr
Copy link

Please provide more info,

  • Reasons for changing
  • Current behavior
  • Expected behavior

@karrtikr karrtikr self-assigned this May 14, 2019
@karrtikr karrtikr added the info-needed Issue requires more information from poster label May 14, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label May 14, 2019
@Cologler
Copy link
Author

Cologler commented May 15, 2019

Seems like this is instance method instead of class method.

@karrtikr
Copy link

karrtikr commented May 15, 2019

Can you please elaborate? With an example perhaps. I don't understand the issue here. Please fill the issue template

@Cologler
Copy link
Author

Cologler commented May 15, 2019

Current behavior:

When user typing def(class method):

def ${1:funcname}(self, ${2:parameter_list}):
    ${3:pass}

Expected behavior:

When user typing def(class method):

@classmethod
def ${1:funcname}(cls, ${2:parameter_list}):
    ${3:pass}

Reason:

The current behavior is not the class method, why did you name it class method ?

@karrtikr
Copy link

karrtikr commented May 15, 2019

Thanks a lot for elaborating. I see what you're saying.

Prescribed solution

Replace

"def(class method)": {
    "prefix": "def(class method)",
    "body": [
        "def ${1:funcname}(self, ${2:parameter_list}):",
        "\t${3:pass}"
    ],
    "description": "Code snippet for a class method"
},,

with

"def(instance method)": {
    "prefix": "def(instance method)",
    "body": [
        "def ${1:funcname}(self, ${2:parameter_list}):",
        "\t${3:pass}"
    ],
    "description": "Code snippet for a instance method"
},
"def(class method)": {
    "prefix": "def(class method)",
    "body": [ 
        "@classmethod",
        "def ${1:funcname}(cls, ${2:parameter_list}):", 
        "\t${3:pass}" 
    ],
    "description": "Code snippet for a class method"
},

@karrtikr karrtikr added feature-code documentation debt Covers everything internal: CI, testing, refactoring of the codebase, etc. and removed info-needed Issue requires more information from poster triage labels May 15, 2019
@karrtikr karrtikr removed their assignment May 15, 2019
@brettcannon brettcannon added the area-editor-* User-facing catch-all label Oct 21, 2019
@brettcannon brettcannon added bug Issue identified by VS Code Team member as probable bug and removed debt Covers everything internal: CI, testing, refactoring of the codebase, etc. labels Nov 25, 2019
@brettcannon
Copy link
Member

I would actually just name it "method" as that's what everyone is going to look for as the name.

@brettcannon brettcannon added area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. and removed feature-code documentation labels Apr 9, 2020
@janosh
Copy link

janosh commented Dec 10, 2020

This looks like an easy fix that fell under the table. Shall I submit the PR?

@brettcannon
Copy link
Member

@janosh I would hold off as we are considering dropping all of our snippets.

@janosh
Copy link

janosh commented Dec 10, 2020

Interesting. Where is that being tracked?

Ah, here: #14781

@brettcannon
Copy link
Member

@janosh correct, we have no control over user-defined snippets, so you can totally have your own copy (or even create your own extension of Python snippets!).

@brettcannon
Copy link
Member

Snippets have been removed by #15006, so closing this as out of date.

@ghost ghost removed the needs PR label Dec 18, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-editor-* User-facing catch-all area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

4 participants