Skip to content
3 changes: 2 additions & 1 deletion mypy/test/config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations

import os.path
from pathlib import PurePath

provided_prefix = os.getenv("MYPY_TEST_PREFIX", None)
if provided_prefix:
PREFIX = provided_prefix
else:
this_file_dir = os.path.dirname(os.path.realpath(__file__))
this_file_dir = os.path.dirname(PurePath(__file__))
PREFIX = os.path.dirname(os.path.dirname(this_file_dir))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, I was thinking that we can replace os.path.dirname with the relevant pathlib operation (this_file_dir = (Path(__file__) / '..').resolve()?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an advantage of doing this over just this_file_dir = (Path(__file__)).resolve().parent ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I just don't know pathlib APIs...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can also use .parent. Maybe you'll need to do str(...) to make sure it's a string path at the end, though...

On the other hand, maybe it would be nice to replace all os.path with pathlib.Path native things in this file? Up to you!


# Location of test data files such as test case descriptions.
Expand Down