Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Using the slash "/" operator between a PurePath and a str should have an inferred type of PurePath #1242

Description

Environment data

  • VS Code version: 1.35.1
  • Extension version (available under the Extensions sidebar): 2019.5.18875
  • OS and version: Ubuntu 18.04
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: standard library pathlib

Expected behaviour

Using the / operator on a pathlib.PurePath and a str should infer a type of pathlib.PurePath.

Given the following Python fragment:

import pathlib

root = pathlib.Path("/some/directory")
subdir = root / "subdir"
child = subdir / "file.txt"

root should have an infered type of Path ✔️
subdir should have an an infered type of PurePath ✔️
child should have an an infered type of PurePath

Actual behaviour

root has an infered type of Path ✔️
subdir has an infered type of PurePath ✔️
child has an infered type of str

Steps to reproduce:

  1. Copy the code above into a new Python file in VS code.
  2. Hover over child, or trigger autocomplete with its methods (the completion is for str).

Selection_063

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Microsoft Python language server.
##########Linting Output - mypy##########
##########Linting Output - flake8##########
[Info  - 9:15:03 AM] Analysis cache path: /home/user/.cache/Microsoft/Python Language Server
[Info  - 9:15:03 AM] GetCurrentSearchPaths /home/user/anaconda3/bin/python 
[Info  - 9:15:03 AM] Interpreter search paths:
[Info  - 9:15:03 AM]     /home/user/anaconda3/lib/python3.6
[Info  - 9:15:03 AM]     /home/user/anaconda3/lib/python3.6/lib-dynload
[Info  - 9:15:03 AM]     /home/user/anaconda3/lib/python3.6/site-packages
[Info  - 9:15:03 AM] User search paths:
[Info  - 9:15:04 AM] Microsoft Python Language Server version 0.3.16.0
[Info  - 9:15:04 AM] Initializing for /home/user/anaconda3/bin/python

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions