Pylance-release: Issue with variant selection in f-strings.

Created on 20 Aug 2020  路  4Comments  路  Source: microsoft/pylance-release

Environment data

  • Language Server version: Pylance language server 2020.8.0
  • OS and version: Win 10 - 2004, 20175.1000
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.5

Expected behaviour

Correctly identify the variant selector following a unicode emoji in an f-string.

Actual behaviour

Raises a warning stating unexpected token and "VARIATION" is not defined.

Code Snippet / Additional information

variable = f"\N{BLACK QUESTION MARK ORNAMENT}\N{VARIATION SELECTOR-16}"

This is pretty much what produced the output below.

鈽旓笍TwinMediumforestgreenGerbil馃悐

bug fixed in next version

Most helpful comment

Thanks again for reporting this. I've introduced a fix, and it will be included in an upcoming version of Pylance. I don't know if it will make it into this week's build.

All 4 comments

I didn't realize that "-" was an allowed character in a "\N" escape. The Python spec on lexical analysis is vague about what it accepts here. It simply says:

\N{name} : Character named聽name聽in the Unicode database

Do you happen to know if there are other characters besides a-zA-Z0-9 and "-" within a Unicode name?

I haven't had any other warning/error occur apart from this specific one.

Thanks again for reporting this. I've introduced a fix, and it will be included in an upcoming version of Pylance. I don't know if it will make it into this week's build.

This issue has been fixed in version 2020.8.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202082-20-august-2020

Was this page helpful?
0 / 5 - 0 ratings