Giter VIP home page Giter VIP logo

Comments (13)

pwwang avatar pwwang commented on May 16, 2024 1

For the pytest issue, see if this helps:

https://stackoverflow.com/questions/47744076/preventing-pytest-from-creating-cache-directories-in-pycharm

from python-varname.

pwwang avatar pwwang commented on May 16, 2024

Could you share your piece of functioning code and your running environment (i.e. python version, whether code is running in a python file, REPL or jupyter)?

from python-varname.

VincentPelletier1 avatar VincentPelletier1 commented on May 16, 2024

The code running is unfortunately too big to share, but I can give information about its environnement:
python 3.7.5 is installed with the following env:
PyNaCl | 1.5.0 | 1.5.0
PyVISA | 1.10.1 | 1.12.0
PyYAML | 6.0 | 6.0
asttokens | 2.0.5 | 2.0.5
atomicwrites | 1.4.0 | 1.4.0
attrs | 21.4.0 | 21.4.0
awg | 1.7.0 | 0.1.1
bcrypt | 3.2.2 | 3.2.2
cachy | 0.3.0 | 0.3.0
certifi | 2022.6.15 | 2022.6.15
cffi | 1.15.0 | 1.15.0
charset-normalizer | 2.0.12 | 2.1.0
cleo | 0.8.1 | 0.8.1
clikit | 0.6.2 | 0.6.2
clock-divider | 1.0.0 |  
colorama | 0.4.4 | 0.4.5
communication-interface | 0.2.0a0 |  
coverage | 6.4.1 | 6.4.1
crashtest | 0.3.1 | 0.3.1
cryptography | 37.0.2 | 37.0.3
distlib | 0.3.4 | 0.3.4
docker | 4.4.4 | 5.0.3
docstring-parser | 0.14.1 | 0.14.1
executing | 0.8.3 | 0.8.3
filelock | 3.7.1 | 3.7.1
future | 0.18.2 | 0.18.2
html5lib | 1.1 | 1.1
idna | 3.3 | 3.3
importlib-metadata | 4.11.3 | 4.12.0
importlib-resources | 5.4.0 | 5.8.0
iniconfig | 1.1.1 | 1.1.1
jsonref | 0.2 | 0.2
jsonschema | 4.4.0 | 4.6.1
keyring | 22.3.0 | 23.6.0
le-compatibility-matrix | 1.18.0 |  
le-config-navigator | 0.3.0 |  
le-constants | 1.8.0 |  
le-eval-board | 1.0.5 |  
le-scpi | 1.0.1 |  
le-simulator | 1.0.1 |  
le-test-as | 2.1.3 |  
le-test-frame | 2.3.4 |  
lockfile | 0.12.2 | 0.12.2
mf-io-board | 0.1.4 |  
more-itertools | 8.12.0 | 8.13.0
msgpack | 1.0.4 | 1.0.4
nifpga | 19.0.0 | 20.0.0
numpy | 1.21.1 | 1.23.0
oscilloscope | 1.4.0 | 0.0.4
packaging | 20.9 | 21.3
pandas | 1.1.5 | 1.4.3
paramiko | 2.11.0 | 2.11.0
pastel | 0.2.1 | 0.2.1
pefile | 2021.5.24 | 2022.5.30
pexpect | 4.8.0 | 4.8.0
pip | 22.1.2 | 22.1.2
pkginfo | 1.8.3 | 1.8.3
platformdirs | 2.5.2 | 2.5.2
pluggy | 0.13.1 | 1.0.0
poetry | 1.1.13 | 1.1.13
poetry-core | 1.0.8 | 1.0.8
psutil | 5.9.1 | 5.9.1
ptyprocess | 0.7.0 | 0.7.0
pure-eval | 0.2.2 | 0.2.2
py | 1.11.0 | 1.11.0
pycparser | 2.21 | 2.21
pylev | 1.4.0 | 1.4.0
pyparsing | 2.4.7 | 3.0.9
pyrsistent | 0.18.1 | 0.18.1
pyserial | 3.5 | 3.5
pytest | 5.4.3 | 7.1.2
pytest-check | 0.3.7 |  
pytest-cov | 3.0.0 | 3.0.0
pytest-html | 3.1.1 | 3.1.1
pytest-metadata | 1.11.0 | 2.0.1
pytest-reportlog | 0.1.2 | 0.1.2
python-dateutil | 2.8.2 | 2.8.2
pytz | 2022.1 | 2022.1
pywin32 | 228 | 304
pywin32-ctypes | 0.2.0 | 0.2.0
requests | 2.28.0 | 2.28.0
requests-toolbelt | 0.9.1 | 0.9.1
scipy | 1.6.1 | 1.8.1
sdkwrapper | 3.1.1a0 |  
semver | 2.13.0 | 2.13.0
setuptools | 60.2.0 | 62.6.0
shellingham | 1.4.0 | 1.4.0
six | 1.16.0 | 1.16.0
smu-core | 1.2.1 |  
tomli | 2.0.1 | 2.0.1
tomlkit | 0.11.0 | 0.11.0
types-PyYAML | 6.0.7 | 6.0.9
types-cryptography | 3.3.21 | 3.3.21
types-paramiko | 2.10.0 | 2.11.1
typing-extensions | 4.1.1 | 4.2.0
urllib3 | 1.26.9 | 1.26.9
varname | 0.8.3 | 0.8.3
virtualenv | 20.15.0 | 20.15.0
wcwidth | 0.2.5 | 0.2.5
webencodings | 0.5.1 | 0.5.1
websocket-client | 1.3.3 | 1.3.3
wheel | 0.37.1 | 0.37.1
zhinst | 20.1.2199 | 22.2.29711
zipp | 3.7.0 | 3.8.0

Note that I also invalidated the cache (I'm using pycharm) and it did not fix the problem.

from python-varname.

pwwang avatar pwwang commented on May 16, 2024

Is there any chance that this is related to #75 ?

from python-varname.

VincentPelletier1 avatar VincentPelletier1 commented on May 16, 2024

It is the same error, but the behavior I have is a bit more erratic. I've just come back from lunch, restarted the terminal and the error seems to be gone for the moment.

I know Pycharm can have some performance issues at times, so maybe this is what I'm witnessing.

from python-varname.

pwwang avatar pwwang commented on May 16, 2024

varname requires the source code to be seen at runtime.

I myself am not a PyCharm user, but I do see people reporting in some cases the code is executed with exec() (where the source code is not seen at runtime).

However, your case is a little wired as the error is not raised consistently.

Let's see if we could gather more info.

from python-varname.

VincentPelletier1 avatar VincentPelletier1 commented on May 16, 2024

One thing I changed was to remove the nameof() method from my nested loops since this is where the code was stopping. I doubt this is the problem, but maybe it could be related.

from python-varname.

pwwang avatar pwwang commented on May 16, 2024

What matters is how it's executed, rather than where it's executed.

from python-varname.

pwwang avatar pwwang commented on May 16, 2024

I guess a sketch of your code will give more help.

from python-varname.

VincentPelletier1 avatar VincentPelletier1 commented on May 16, 2024
def meta_tag_replacement(mocked_ileddarspapi: MagicMock) -> MagicMock:
    mocked_ileddarspapi_name = nameof(mocked_ileddarspapi)
    method_to_mock = {
        'buildMetadataTag':
        {
            'buildAttributes': [100],
            'buildNumber': 100,
            'commitId': 100
        }
    }
    method_list = []

    [method_list.append(method) for method in dir(mocked_ileddarspapi.VersionGet_PWrap()[1]) if
     method not in dir(object) if not method.startswith('__') if method not in dir(MagicMock)]

    mocked_ileddarspapi.VersionGet_PWrap.return_value = (OUTPUT_STATUS, MagicMock(mocked_ileddarspapi.VersionGet_PWrap()[1]))

    for method in method_list:
        if method not in dir(object) and not method.startswith('__') and method not in dir(MagicMock) and method in method_to_mock.keys():
            for method_to_change in method_to_mock[method].keys():
                eval(mocked_ileddarspapi_name + '.' + nameof(mocked_ileddarspapi.VersionGet_PWrap) + '.' + method + '.' + method_to_change).return_value = method_to_mock[method][method_to_change]

    return mocked_ileddarspapi

from python-varname.

VincentPelletier1 avatar VincentPelletier1 commented on May 16, 2024

I've left a single nameof() instance inside the double for loop to show where the nameof() was initially.

from python-varname.

pwwang avatar pwwang commented on May 16, 2024
  1. Does it make any difference if we save nameof(mocked_ileddarspapi.VersionGet_PWrap) outside the loops:
    # your code
    # ...
    mocked_ileddarspapi_versionget_pwrap = nameof(mocked_ileddarspapi.VersionGet_PWrap)
    for ...
        if ....
            for ...
                eval(mocked_ileddarspapi_name + '.' + mocked_ileddarspapi_versionget_pwrap + '.' + method + '.' + method_to_change).return_value = method_to_mock[method][method_to_change]
  1. If you intended to use nameof() here, then it's not necessary, since nameof(mocked_ileddarspapi) is literally "mocked_ileddarspapi" and nameof(mocked_ileddarspapi.VersionGet_PWrap) is literally "VersionGet_PWrap". You probably meant to use argname()

from python-varname.

VincentPelletier1 avatar VincentPelletier1 commented on May 16, 2024

I tried putting the nameof() out of the loop's context, but it didn't change a thing. However, I found out that starting an instance of pytest at the same time does yield the error I first stated, but even more than that: it seems to latch onto the error even after the pytest program is killed and its terminal deleted.

(I'll try argname! Thanks for the tip) --> still the error remains

from python-varname.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.