5 ms·
I wonder if the author has ever heard something called an IDE?
by nfrankel 2y ago
I wonder if the author has ever heard something called an IDE?
- lispisok 2y agoyes but how does the IDE do it?
- ErikBjare 2y agoI think this particular case would be difficult to refactor even in an IDE like PyCharm, which afaik is the best at refactoring Python (might be outdated).
- rustyminnow 2y agoWhat's an IDE and how does it refactor hundreds of semantically unrelated identifiers in one go?
- cstrahan 2y agoI’m not a Python developer, but… I believe the idea is that those identifiers are semantically related: that fixture decorator inspects the formal parameter names so that it can pass the appropriate arguments to each test when the tests are run. A sufficiently smart IDE and/or language server would thus know that these identifiers are related, and performing a rename on one instance would thus rename all of the others. And maybe you were being facetious, but an IDE is an “Integrated Development Environment”. Edit: Yep. Took all of 60 seconds to find what I’m looking for, as I type this from my phone while sitting in my throne room: https://docs.pytest.org/en/6.2.x/fixture.html https://docs.pytest.org/en/6.2.x/fixture.html See the “Fixtures can request other fixtures” section, which describes the scenario from TFA. And this post describes the PyCharm support for refactoring fixtures: https://www.jetbrains.com/guide/pytest/tutorials/visual_pytest/fixtures/ https://www.jetbrains.com/guide/pytest/tutorials/visual_pyte...
- fiddlerwoaroof 2y agoIDEs are great if your refactorings fit in the predefined refactorings
- Jackevansevo 2y agoAuthor here, I'm not aware of any IDE that can do this specific refactor
- morningsam 2y agoPyCharm understands pytest fixtures and if this is really just about a single fixture called "database", it takes 3 seconds to do this refactoring by just renaming it.
- 1-more 2y agoWrite instructions on how to do this in any IDE.
- morningsam 2y agoIn PyCharm: Move cursor on any occurence or definition of "database" fixture, press the "Rename" hotkey (Shift+F6), delete old name and type new name, press Enter key to confirm.
- 1-more 2y agoWouldn’t that be limited to the single function?
- morningsam 2y agoA single fixture, yes. If there are many fixtures of the same name in different test modules, it wouldn't work, but that's not how I understood the problem in the blog post, which says >rename every instance of a pytest fixture from database -> db Every instance of a fixture, not every instance of all fixtures of the same name.
- cstrahan 2y agoThe fine folks at JetBrains already have done just that: https://www.jetbrains.com/guide/pytest/tutorials/visual_pytest/fixtures/ https://www.jetbrains.com/guide/pytest/tutorials/visual_pyte...
- 1-more 2y agoI don’t think that this will handle what the author wants, though. If each function takes db as an argument and uses it internally, those don’t count as references that you can change globally, right?