stm_app icon indicating copy to clipboard operation
stm_app copied to clipboard

Local imports matched to incorrect file type

Open rimutaka opened this issue 4 years ago • 1 comments

The current implementation of the local import identification doesn't take the file type into account.

For example import logging in a .py Python file will match on scripts/logging.js because:

  1. the matcher is unaware of the current file type
  2. there may be multiple file extensions that can be a legit match, e.g. .js` and .ts

The matcher should be aware of both those conditions to solve this problem.

As a result, some imports are deemed local when they are not.

Example from Ascalon0823___Arkademy

Apr 05 09:56:27.821  INFO pu{idx=0}: stackmuncher::tech: Removing local import: System / Assets/Plugins/UniRx/Scripts/System.meta
Apr 05 09:56:27.827  INFO pu{idx=0}: stackmuncher::tech: Removing local import: System / Assets/Plugins/UniRx/Scripts/System.meta
Apr 05 09:56:27.833  INFO pu{idx=0}: stackmuncher::tech: Removing local import: System / Assets/Plugins/UniRx/Scripts/System.meta
Apr 05 09:56:27.839  INFO pu{idx=0}: stackmuncher::tech: Removing local import: System / Assets/Plugins/UniRx/Scripts/System.meta
Apr 05 09:56:27.839  INFO pu{idx=0}: stackmuncher::tech: Removing local import: UniRx / Assets/Plugins/UniRx/Scripts/UniRx.asmdef
Apr 05 09:56:27.844  INFO pu{idx=0}: stackmuncher::tech: Removing local import: System / Assets/Plugins/UniRx/Scripts/System.meta

Example:

Apr 05 10:01:51.362  INFO pu{idx=1}: stackmuncher::tech: Removing local import: json / NETCoreExperimentalWebApp/wwwroot/lib/semantic/semantic.json.example
Apr 05 10:01:51.362  INFO pu{idx=1}: stackmuncher::tech: Removing local import: common / NETCoreExperimentalWebApp/wwwroot/lib/google-blockly-941d8e4/i18n/common.py

rimutaka avatar Apr 05 '21 03:04 rimutaka

A list of resources I used to make Python Regex:

  • https://github.com/search?p=2&q=import+pycrypto&type=Code
  • https://docs.python-guide.org/writing/structure/
  • https://pip.pypa.io/en/stable/user_guide/
  • https://packaging.python.org/guides/tool-recommendations/
  • https://packaging.python.org/tutorials/installing-packages/

rimutaka avatar Apr 11 '21 05:04 rimutaka