Skip to content

Typing for scrapy.settings.BaseSettings #5977

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

Merged
merged 5 commits into from
Jul 24, 2023
Merged

Typing for scrapy.settings.BaseSettings #5977

merged 5 commits into from
Jul 24, 2023

Conversation

wRAR
Copy link
Member

@wRAR wRAR commented Jul 16, 2023

This adds full typing for BaseSettings. There is one potential optimisation here: BaseSettings is both the Scrapy settings as a whole (with keys that can only be strings) and setting values for things like FEEDS (with keys of various types), if it's possible to separate these it's possible to type the former more correctly. But that seems to require changing the class hierarchy and so it's more harm than good.

Another things that is out of scope and not really useful is Settings vs BaseSettings in the annotations of the code that uses settings. The code difference between those classes is only the __init__ method so their interfaces are currently identical.

@codecov
Copy link

codecov bot commented Jul 16, 2023

Codecov Report

Merging #5977 (739085d) into master (b619630) will decrease coverage by 0.02%.
The diff coverage is 93.33%.

❗ Current head 739085d differs from pull request most recent head 5e15824. Consider uploading reports for the commit 5e15824 to get more accurate results

@@            Coverage Diff             @@
##           master    #5977      +/-   ##
==========================================
- Coverage   89.19%   89.17%   -0.02%     
==========================================
  Files         162      162              
  Lines       11287    11317      +30     
  Branches     1833     1838       +5     
==========================================
+ Hits        10067    10092      +25     
- Misses        928      931       +3     
- Partials      292      294       +2     
Impacted Files Coverage Δ
scrapy/crawler.py 87.37% <ø> (ø)
scrapy/cmdline.py 68.70% <75.00%> (+0.73%) ⬆️
scrapy/settings/__init__.py 95.40% <90.76%> (-2.94%) ⬇️
scrapy/exporters.py 100.00% <100.00%> (ø)
scrapy/extensions/feedexport.py 95.63% <100.00%> (-0.19%) ⬇️
scrapy/settings/default_settings.py 98.77% <100.00%> (ø)
scrapy/utils/conf.py 92.30% <100.00%> (+0.06%) ⬆️
scrapy/utils/project.py 78.84% <100.00%> (ø)

... and 1 file with indirect coverage changes

@wRAR wRAR merged commit 6e3e3c2 into master Jul 24, 2023
@wRAR wRAR deleted the typing-settings branch July 24, 2023 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants