Skip to content

feat: Add local/global configuration support for #203. - #225

Closed
supakeen wants to merge 2 commits into
scanapi:masterfrom
supakeen:configuration-file
Closed

supakeen wants to merge 2 commits into
scanapi:masterfrom
supakeen:configuration-file

Conversation

@supakeen

@supakeen supakeen commented Jul 25, 2020

Copy link
Copy Markdown
Contributor

Initial support for a different configuration filename and global configuration.

closes #203

@supakeen

supakeen commented Jul 25, 2020

Copy link
Copy Markdown
Contributor Author
  • Use has_global_config_file.
  • Don't merge global/local.

@supakeen
supakeen marked this pull request as ready for review July 25, 2020 16:23
Comment thread scanapi/settings.py

user_config = load_config_file(config_path)
self.update(**user_config)
if config_path:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey, can we have some tests to this part?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here we have some guidelines for testing with you want to take a look at it: https://github.com/scanapi/scanapi/blob/master/CONTRIBUTING.md#tests

Let me know if you need any help!

@supakeen

supakeen commented Jul 26, 2020

Copy link
Copy Markdown
Contributor Author
  • More tests.
  • Rebase.

Comment thread scanapi/config_loader.py
return json.load(f)
else:
raise FileFormatNotSupportedError(f".{extension}", relative_path)
return yaml.load(f, Loader)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know is just 2 lines of code, but can we use a more meaningful name rather than just a single letter? :/
How about

Suggested change
return yaml.load(f, Loader)
return yaml.load(file_hander, Loader)

instead? Don't forget to update line 37 if you accept this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If anything I'd pick file or handle which are both better than f, which one do you prefer?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe handle, as I'm not sure right now if file is a reserved name/module in python. That's why suggested file_handler.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

file is the name of a builtin in Python 2, but not in Python 3 :)

@vinigfer vinigfer Aug 4, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did not know that! Unfortunately I'm still stuck with some Python 2 projects :(
Guess we can go with file then

Comment thread scanapi/scan.py
Comment on lines +35 to 36
except yaml.YAMLError as e:
logger.error(e)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe

Suggested change
except yaml.YAMLError as e:
logger.error(e)
except yaml.YAMLError as excep:
logger.error(excep)

instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

e is a pretty common name so this one I'm unsure about.

Comment thread scanapi/settings.py Outdated
Comment on lines 21 to 24
if not any(
[config_path, self.has_local_config_file, self.has_global_config_file]
):
return

@vinigfer vinigfer Aug 1, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really need these check? The next couple of lines will perform if-elifs, and if all options are false, then it will already (implicitly) return None, like what is being done over here.

Suggested change
if not any(
[config_path, self.has_local_config_file, self.has_global_config_file]
):
return

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea I agree I'll change that.

@vinigfer vinigfer changed the title Add local/global configuration support for #203. feat: Add local/global configuration support for #203. Aug 1, 2020
@camilamaia

Copy link
Copy Markdown
Member

@supakeen hey, do you intend to keep working on this PR? Or do you want me to get it from here?

@supakeen

Copy link
Copy Markdown
Contributor Author

@camilamaia If I don't do it this weekend you can take it but my plan is to get it done then :)

@supakeen
supakeen requested review from a team as code owners August 16, 2020 16:57
@supakeen

supakeen commented Aug 16, 2020

Copy link
Copy Markdown
Contributor Author

Hey, I've changed the review requests but I'm now slightly confused while rebasing. It seems master has a new DEFAULT_CONFIG_PATH, how does this fit in with the changes here or is it just a rename of GLOBAL_CONFIG_PATH or LOCAL_CONFIG_PATH?

@supakeen

Copy link
Copy Markdown
Contributor Author

There we go, I think I got the rebase working. @camilamaia I don't have time in the foreseeable future due to holiday season here to add testcases as well perhaps someone could take over this PR for that? :)

@camilamaia

Copy link
Copy Markdown
Member

@supakeen great, no problem! I will take it, thanks for the effort!

@camilamaia

Copy link
Copy Markdown
Member

Closed by #254

@camilamaia camilamaia closed this Aug 24, 2020
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.

Change config file default name

3 participants