atom / language-python

Python package for Atom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dot suggests autocomplete to self

ShadowLNC opened this issue · comments

Prerequisites

Description

Atom suggests an autocomplete of "self" when I type a dot/period/full stop (".").

I would like to disable this autocomplete suggestion. PEP8 specifies comments should be grammatically valid, so when I end with a full stop, it suggests this, and when I press enter to go to a new line, it instead prepends "self" to the full stop.

Steps to Reproduce

  1. Open a Python file.
  2. Type some text, e.g. "a".
  3. Type a dot.

Expected behavior: No autocomplete suggestions.

Actual behavior: Autocomplete suggests "self", even in a comment.

Reproduces how often: 100%

Versions

atom --version
Atom    : 1.28.0
Electron: 2.0.3
Chrome  : 61.0.3163.100
Node    : 8.9.3

apm --version
apm  1.19.0
npm  3.10.10
node 6.9.5 x64
atom 1.28.0
python 3.6.4
git 2.15.0.windows.1
visual studio

The OS is Windows 10 Pro 64-bit, version 1803 (build 17134.112).

Additional Information

This does not occur on a dot that begins a line (or follows a space), only for a dot that follows text. I feel like the intended behaviour might be the opposite (should only suggest following a space or newline), i.e. there might be an inverted conditional.

I believe this to be a bug, but if the behaviour is intended, I would like to turn it off (just the "self" suggestion), in which case please consider it a feature request. I believe it's part of the langugage-python package, as it occurs in safe mode, and only in Python files, so apologies if I've gotten this wrong.

A very annoying behavior indeed!

For what it's worth, I've also noticed this behavior and I'm running a Mac OS on High Sierra (10.13.6). Atom version 1.28.1 x64 .

(It's been driving me crazy for weeks, which is the only reason that I'm still doing the bulk of my coding in VSCode instead of switching over)

Looks like it might have to do with:

'.source.python:not(.string)':
  'self':
    'prefix': '.'
    'body': 'self.'

in https://github.com/atom/language-python/blob/master/snippets/language-python.cson

A temporary way around this issue might be to locally disable the incriminated snippet. Users can add this to their ~/.atom/snippets.cson:

'.source.python:not(.string)':
  'self':
    'prefix': '.'
    disabled: true

@j2bbayle: this is a lifesaver :)

A temporary way around this issue might be to locally disable the incriminated snippet. Users can add this to their ~/.atom/snippets.cson:

'.source.python:not(.string)':
  'self':
    'prefix': '.'
    disabled: true

Thank you!