-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide default values for mirror config options #1740
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1740 +/- ##
==========================================
+ Coverage 79.69% 83.69% +4.00%
==========================================
Files 31 33 +2
Lines 4324 4380 +56
Branches 780 783 +3
==========================================
+ Hits 3446 3666 +220
+ Misses 721 531 -190
- Partials 157 183 +26 ☔ View full report in Codecov by Sentry. |
This splits the existing 'default.conf' config file shipped with the package into two similar files: "defaults.conf" and "example.conf". "example.conf" is an exact copy of the previous "default.conf". The new "defaults.conf" is a stripped-down version containing only default values for all mirror configuration options except "mirror.directory". BandersnatchConfig is changed to *always* read defaults.conf, then read the user config file if one is specified. This leaves the ConfigParser populated with default values for any mirror options that aren't set by the user (except mirror.directory). Notable ripple effects for this include: - It is no longer meaningful to check ConfigParser.has_option with the 'mirror' section. Instead, you have to check whether the options value is empty or None. - Specifying a default/fallback value when calling .get on the 'mirror' section will have no effect, because the option will already be present in the ConfigParser mappings. As (mostly) an implementation detail, BandersnatchConfig is changed to be a subclass of ConfigParser. The BandersnatchConfig singleton can be used anywhere a ConfigParser instance is expected without having to use '.config' to access a nested ConfigParser. Fixes pypa#1702 Fixes pypa#990
Add default values for options that are no longer required.
d34599f
to
146fd1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a nice refactor and cleanup. Many thanks!
Co-authored-by: Cooper Lees <[email protected]>
(...finally.)
This should be a much more focused PR for addressing issue #1702 without so much additional refactoring.
I've changed the configuration files embedded in the package like so:
-c
argument is passed file that doesn't exist to create a configuration.[mirror]
configuration options except fordirectory
, with minimal annotation.I changed
BandersnatchConfig
:ConfigParser
. Technically this violates the Liskov substitution principal by giving the subtype a different signature for__init__.
I have mixed feelings about that, but this seemed like a much cleaner way to customize ConfigParser and removed many instances ofBandersnatchConfig().config
or similar.Some notable effects of this include:
ConfigParser.has_option
on the 'mirror' section. Instead, you have to check whether the options value is empty or None..get
on the 'mirror' section will have no effect, because the option will already be present in the ConfigParser mappings.Happy to tweak which options are required/have defaults and dynamic fallback behaviors for things like
root_uri
, if that's something we want to change at this point.Fixes #1702
Fixes #990