Skip to content
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

convert django debug codemod to use codemod api #123

Merged
merged 2 commits into from
Nov 9, 2023
Merged

Conversation

clavedeluna
Copy link
Contributor

@clavedeluna clavedeluna commented Nov 9, 2023

Overview

Convert one codemod to use codemod API instead of basecodemod directly. I recognized the opportunity to make this codemod much smaller. Instead of having one codemod class and one transformer, I made it all into one small class. Since this codemod only cares about settings.py files, we can use the fact that visit_Module checks if we should even visit the module. If so, this codemod will run at leave_Assign

If we like this change, I think I can make the same for django cookie secure off codemod

Copy link

codecov bot commented Nov 9, 2023

Codecov Report

Merging #123 (8663e8b) into main (7aaa51f) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
- Coverage   95.96%   95.93%   -0.04%     
==========================================
  Files          64       64              
  Lines        2630     2608      -22     
==========================================
- Hits         2524     2502      -22     
  Misses        106      106              
Files Coverage Δ
src/core_codemods/django_debug_flag_on.py 100.00% <100.00%> (ø)

@clavedeluna
Copy link
Contributor Author

@andrecsilva sorry for asking for review again. I recognized an optimization using visit_Module

Copy link
Contributor

@andrecsilva andrecsilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call on the optimization. Maybe we could use a should_visit_module() method in the API to make it a bit more clear and independent on libcst.

@clavedeluna clavedeluna merged commit 70f7903 into main Nov 9, 2023
11 checks passed
@clavedeluna clavedeluna deleted the use-api branch November 9, 2023 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants