[MRG+1] Remove dependency on os.environ from default settings #1829
Conversation
editor = os.environ['EDITOR'] | ||
except KeyError: pass | ||
else: | ||
settings['EDITOR'] = editor |
kmike
Mar 1, 2016
Member
won't this override EDITOR value set in project settings?
won't this override EDITOR value set in project settings?
nyov
Mar 1, 2016
Author
Contributor
Yes it will. I think... if you have an ENV setting set as a user, that it should always take precedence.
But I see that would change current behavior. Not sure which should be higher valued, project settings or environment (user terminal/shell setting).
Yes it will. I think... if you have an ENV setting set as a user, that it should always take precedence.
But I see that would change current behavior. Not sure which should be higher valued, project settings or environment (user terminal/shell setting).
Current coverage is 83.43% (diff: 55.55%)@@ master #1829 diff @@
==========================================
Files 161 161
Lines 8779 8779
Methods 0 0
Messages 0 0
Branches 1288 1288
==========================================
- Hits 7326 7325 -1
- Misses 1205 1206 +1
Partials 248 248
|
+1 to remove os.environ usage from default_settings |
Thinking about the precedence for Settings are project-bound, but editor is a user setting. I find no reason why anyone would need to store this in a scrapy setting; this is what a user's terminal environment is for and it belongs in Having scrapy care about that setting looks like over-engineering. If I need to store the setting without messing with my ENV, I can use a script in #!/bin/sh
export EDITOR="vim"
scrapy "${@}" Windows users might not like the shell. But they would need to be on one to type |
+1 to removing EDITOR option and hardcoding a fallback to scrapy commands. This is technically backwards incompatible, but it only affects interactive usage, and there is an easy workaround. |
Avoid loading settings from environment in scrapy core. Instead it's better to populate them from the starting shell or an embedding script.
Avoid loading settings from Environment in scrapy core.
(Then it's not a default setting but a user-defined one, by definition.)
Instead it's better to populate them from the starting shell or an embedding script.
Plug: noticed this while in the mindset of scrapy as a library (#1777 (comment)).