Skip to content

Conversation

@fjahr
Copy link
Contributor

@fjahr fjahr commented Jul 30, 2023

fixes #28183

The custom cache dir for mypy can only be set via an environment variable, setting the MYPY_CACHE_DIR variable in the program is not sufficient. This error was introduced while translating the shell script to python.

See also the mypy documentation: https://mypy.readthedocs.io/en/stable/config_file.html#confval-cache_dir

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 30, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK MarcoFalke

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

left some questions

Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Member

Choose a reason for hiding this comment

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

If it is not needed, it may be better to remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added as part of #18210 but I didn't see an explanation given there. I think it is better to specify a location explicitly since the default is using the current directory which may be leading to unexpected results if this script is called from different contexts. But if we don't care about something like this, it may be removed.

Copy link
Member

Choose a reason for hiding this comment

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

This will write to /test/ if a user is running this script:

# ./test/lint/lint-python.py 
Success: no issues found in 269 source files
# ls /test/.mypy_cache/
3.11  CACHEDIR.TAG

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was the previous behavior. There is even an explicit line for this in our .gitignore. What would you like to do instead? Move it into /test/cache/?

Copy link
Member

Choose a reason for hiding this comment

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

No, I mean /test/, not ./test/.

With /test being next to /bin, etc. I don't think .gitignore will work on the literal root of your filesystem. .gitignore should be limited to the folder it is located in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, I simply misread. I changed this to get the base path relative to file as a fallback. We could also simply use . or fall back to not setting a cache_dir at all but this seemed the most robust option to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I simply misread. I changed this to get the base path relative to file as a fallback. We could also simply use . or fall back to not setting a cache_dir at all but this seemed the most robust option to me.

Wouldn't the default option result in placing the cache dir in the root, regardless of where the script is being run from?

@maflcko
Copy link
Member

maflcko commented Aug 15, 2023

Are you still working on this? If not, could close, so that someone else can pick it up?

@achow101 achow101 requested a review from maflcko September 20, 2023 16:23
@fjahr
Copy link
Contributor Author

fjahr commented Sep 20, 2023

Addressed feedback by @MarcoFalke and rebased

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

lgtm, left a nit

@maflcko
Copy link
Member

maflcko commented Oct 1, 2023

lgtm ACK f904777

@fanquake fanquake merged commit 8b44d01 into bitcoin:master Oct 2, 2023
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Oct 5, 2023
f904777 lint: fix custom mypy cache dir setting (Fabian Jahr)

Pull request description:

  fixes bitcoin#28183

  The custom cache dir for `mypy` can only be set via an environment variable, setting the `MYPY_CACHE_DIR` variable in the program is not sufficient. This error was introduced while translating the shell script to python.

  See also the mypy documentation: https://mypy.readthedocs.io/en/stable/config_file.html#confval-cache_dir

ACKs for top commit:
  MarcoFalke:
    lgtm ACK f904777

Tree-SHA512: 7e8fb0cd06688129bd46d1afb8647262eb53d0f60b1ef6f288fedaa122d906fb62c9855e8bb0d6c6297d41a87a47d3cec7a00df55a7d033947937dfe23d07ba7
@bitcoin bitcoin locked and limited conversation to collaborators Oct 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lint: MYPY_CACHE_DIR is unused

5 participants