Replies: 4 comments 1 reply
-
|
Oh, ho, ho. BizarroWorld™ packaging directory structure, huh? Yeah. That's... that's your problem. 🤣 I hope you don't mind, but I've migrated this into a Q&A discussion format for readability and clarity. Please don't mind! You have totally valid concerns, but they probably intersect better with the forum format. Okay. So... As you've correctly surmised:
That's it. That's totally it. You've nailed it in one. This might be surprising. Like @beartype, What
So. What do those two new
Totally works. Right? $ ls
my_package/ my_package_test/
$ pytest
================================================= test session starts =================================================
platform linux -- Python 3.8.19, pytest-7.2.1, pluggy-1.0.0
rootdir: /home/leycec/tmp/
collected 1 item
my_package_test/test_curse_it.py . [100%]
================================================== 1 passed in 0.31s ==================================================@beartype and
|
Beta Was this translation helpful? Give feedback.
-
|
Thank you so much for responding so quickly and comprehensively! I have fixed my crazy directory structure in my toy example, and I believe my problem still remains. Namely, I don't get any errors and don't know how to set things in such a way that I would get errors for incorrect type hints in variable assignments in test files. Alternatively, I'm still making some crazy mistake... Here's my setup.
running |
Beta Was this translation helpful? Give feedback.
-
|
Oh, ho, ho. Madness intensifies. So you want to apply How familiar are you with Was there a pressing reason that you needed |
Beta Was this translation helpful? Give feedback.
-
|
This is likely a meaningless distinction, but I'm not trying to "apply I am not at all familiar with the inner workings of pytest. It's all just copy-paste and magic to me... I'm probably just going to drop this one. It's not too critical and if it sounds like a can of worms to you I'm sure I would be in for a bad time trying to get it to work. A little more about my use case in case you're interested: I recently started using Anyways, Thanks again for your assistance!! Have a beartastic day :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Suppose you have some test:
in some package with
If you are me, then you might spend an embarrassingly long time wondering why this happens
before realizing that this
throws an error
beartype.roar.BeartypeDoorHintViolation: Callable my_package.cursed_test.test_curses() local variable "x" value 'nope' violates type hint <class 'int'>, as str 'nope' not instance of int.Like I expected to happen in the first place and deducing (hopefully correctly, what do I know) that pytest must be executing the tests in some manner that doesn't involve importing the package, thereby sidestepping thebeartype_this_packagehook.I would love for there to be a way to run beartype during test execution with pytest. Note that, even if I'm willing to decorate all my tests with
@beartype, this will still not catch my variable assignment problems.die_if_unbearablesecretly everywhere behavior other than with the package level hook that I've missed? If there were something similar to the@beartypedecorator I could at least manually decorate a bunch of things in the test file.Beta Was this translation helpful? Give feedback.
All reactions