Skip to content

Commit

Permalink
Prepare for release 0.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-hegman committed Aug 31, 2023
1 parent b2aed58 commit 26d9a9b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
**[0.16.0] 2023-08-31**
- Fixed #63: Remote Interpreter
- Fixed #110: Support for mypy using WSL interpreter
- Respect mypy path field and don't force usage of project interpreter

**[0.15.0] 2023-04-24**
- Fixed #107: Icons not visible in new Jetbrains UI
- New: Min IDEA version raised from PC-2021.2 to PC-2022.1.4
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
version=0.15.0
version=0.16.0
ideVersion=PC-2022.1.4
pythonPlugin=python-ce
sinceBuild=221.6008
Expand Down
45 changes: 31 additions & 14 deletions src/main/java/com/leinardi/pycharm/mypy/mpapi/MypyRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.nio.file.Path;

import static java.nio.charset.StandardCharsets.UTF_8;

Expand Down Expand Up @@ -137,6 +138,7 @@ public static String getMypyPath(Project project, boolean checkConfigService) {
return mypyPath;
}
}

VirtualFile interpreterFile = getInterpreterFile(project);
if (isVenv(interpreterFile)) {
VirtualFile mypyFile = LocalFileSystem.getInstance()
Expand All @@ -155,6 +157,12 @@ public static boolean checkMypyAvailable(Project project) {
}

public static boolean checkMypyAvailable(Project project, boolean showNotifications) {
String mypyPath = getMypyPath(project);
boolean isMypyPathValid = !mypyPath.isEmpty() && isMypyPathValid(mypyPath, project);
if (isMypyPathValid) {
return true;
}

Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (projectSdk == null
|| projectSdk.getHomeDirectory() == null
Expand All @@ -173,16 +181,8 @@ public static boolean checkMypyAvailable(Project project, boolean showNotificati
}
}
}
MypyConfigService mypyConfigService = MypyConfigService.getInstance(project);
if (mypyConfigService == null) {
throw new IllegalStateException("MypyConfigService is null");
}
String mypyPath = getMypyPath(project);
boolean isMypyPathValid = !mypyPath.isEmpty() && isMypyPathValid(mypyPath, project);
if (showNotifications && !isMypyPathValid) {
Notifications.showUnableToRunMypy(project);
}
return isMypyPathValid;

return false;
}

private static String getMypyConfigFile(Project project, String mypyConfigFilePath) throws MypyPluginException {
Expand Down Expand Up @@ -382,11 +382,28 @@ private static GeneralCommandLine getMypyCommandLine(Project project, String myp

@Nullable
private static VirtualFile getInterpreterFile(Project project) {
Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (projectSdk != null) {
return projectSdk.getHomeDirectory();
MypyConfigService mypyConfigService = MypyConfigService.getInstance(project);
if (mypyConfigService == null) {
throw new IllegalStateException("MypyConfigService is null");
}
String customMypyPath = mypyConfigService.getCustomMypyPath();
if (!customMypyPath.isEmpty()) {
Path mypyFolder = Path.of(customMypyPath).getParent();
File file = mypyFolder.resolve("python").toFile();
if (!file.exists()) {
return null;
}

LocalFileSystem fileSystem = LocalFileSystem.getInstance();
return fileSystem.findFileByIoFile(file);

} else {
Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();
if (projectSdk != null) {
return projectSdk.getHomeDirectory();
}
return null;
}
return null;
}

private static void injectEnvironmentVariables(Project project, GeneralCommandLine cmd) {
Expand Down

0 comments on commit 26d9a9b

Please sign in to comment.